NUMERIC

Name

NUMERIC -- 

Function

nPositive           ABS(<nExp>)
nCode               ASC(<cExp>)
TRUE || FALSE       BETWEEN(<TargetData>, <FirstData>, <SecondData>)
nNumber             BIN2I(<cSignedInt>)
nNumber             BIN2L(<cSignedInt>)
nNumber             BIN2W(<cUnsignedInt>)
cChar               CHR(<nCode>)
<nValue>            DSTRTON(<sString>)
lEmpty              EMPTY(<exp>)
nAntilogarithm      EXP(<nExponent>)
<nValue>            FSTRTON(<sString>)
nGCD                FT_GCD( <nNumber1>, <nNumber2> )
nNetPV              FT_NETPV( <nInitialInvestment>, <nInterestRate>, <aCashFlow> ; [, <nNoOfCashFlows> ] )
nRand               FT_RAND1( <nMax> )
nNumber             FT_ROUND( <nNumber> [, <nRoundToAmount>           ; [, <cRoundType>  [, <cRoundDirection>   ; [, <nAcceptableError> ] ] ] ] )
<sStr>              HASHNAME(<nHashCode>)
<nHashCode>         HASHSTR(<sStr>)
cBinaryInteger      I2BIN(<nInteger>)
nInteger            INT(<nExp>)
lBoolean            ISDIGIT(<cString>)
cBinaryInteger      L2BIN(<nExp>)
nCount              LEN(<cString> | <aTarget>)
nNaturalLog         LOG(<nExp>)
dLarger             MAX(<nExp1>, <nExp2>) --> nLarger MAX(<dExp1>, <dExp2>)
dSmaller            MIN(<nExp1>, <nExp2>) --> nSmaller MIN(<dExp1>, <dExp2>)
nRemainder          MOD(<nDividend>, <nDivisor>)
NIL                 QOUT([<exp list>]) --> NIL QQOUT([<exp list>])
nRounded            ROUND(<nNumber>, <nDecimals>)
nRoot               SQRT(<nNumber>)
cFormatString       TRANSFORM(<exp>, <cSayPicture>)
cType               TYPE(<cExp>)
nNumber             VAL(<cNumber>)
cType               VALTYPE(<exp>)

Description

Function ABS()

 ABS(<nExp>) --> nPositive

ABS() is a numeric function that determines the magnitude of a numeric value independent of its sign. It lets you, for example, obtain the difference between two numbers as a positive value without knowing in advance which of the two is larger.

As a formalism, ABS(x) is defined in terms of its argument, x, as follows: if x >= 0, ABS(x) returns x; otherwise, ABS(x) returns the negation of x.

Function BIN2I()

 BIN2I(<cSignedInt>) --> nNumber

BIN2I() is a low-level file function that is used with FREAD() to convert a two-byte character string formatted as a signed integer to a xClipper numeric data type. This is most useful when you are reading foreign file types and want to read numeric data in its native format.

Function BIN2L()

 BIN2L(<cSignedInt>) --> nNumber

BIN2L() is a low-level file function that is used with FREAD() to convert a four-byte character string formatted as a signed integer to a xClipper numeric data type. This is most useful when you are reading foreign file types and want to read numeric data in its native format.

Function BIN2W()

 BIN2W(<cUnsignedInt>) --> nNumber

BIN2W() is a low-level file function that is used with FREAD() to convert a two-byte character string formatted as an unsigned integer to a xClipper numeric data type. This is most useful when you are reading from a binary file and want to read data in its native format.

Function EXP()

 EXP(<nExponent>) --> nAntilogarithm

EXP() is a mathematical function that calculates the value, y, (the antilogarithm) of the following equation,

e**x = y

where e is the base of natural logarithms (2.71828...) and x is <nExponent>. The maximum value of <nExponent> is 45 before a numeric overflow occurs. EXP() and LOG() are inverse functions.

The number of decimal places displayed is determined solely by SET DECIMALS regardless of the current SET FIXED value.

Function FT_GCD()

 FT_GCD( <nNumber1>, <nNumber2> ) --> nGCD

This function calculates the greatest common divisor between 2 numbers, i.e., the largest number that will divide into both numbers evenly. It will return zero (0) if either number is zero.

Function FT_NETPV()

 FT_NETPV( <nInitialInvestment>, <nInterestRate>, <aCashFlow> ;
 [, <nNoOfCashFlows> ] ) --> nNetPV

This function calculates the net present value, the difference between the cost of an initial investment and the present value of the expected cash flow(s) from the investment. The present value of the expected cashflow(s) is calculated at the specified interest rate, which is often referred to as the "cost of capital".

This function can be used to evaluate alternative investments. The larger the NPV, the more profitable the investment. See also the FutureValue and PresentValue for further explanations. The formula to calculate the net present value is:

NetPresentValue = SUM(CashFlow[i] / ((1 + InterestRate) ** i)) FOR i = 1 TO NoOfCashFlows

Function FT_RAND1()

 FT_RAND1( <nMax> ) --> nRand

Generates a non-integer random number based on the Linear Congruential Method.

If you need a random number between 1 and <nMax> inclusive, INT() the result and add 1.

If you need a random number between 0 and <nMax> inclusive, then you should ROUND() the result.

Function FT_ROUND()

 FT_ROUND( <nNumber> [, <nRoundToAmount>           ;
 [, <cRoundType>  [, <cRoundDirection>   ;
 [, <nAcceptableError> ] ] ] ] )           --> nNumber

This function will allow you to round a number. The following can be specified: a. Direction (up, down or normal - normal is 4/5 convention) b. Type (whole, decimal, fraction) c. Amount (100's, 5 decimals, 16th, etc.)

Function I2BIN()

 I2BIN(<nInteger>) --> cBinaryInteger

I2BIN() is a low-level file function that converts an integer numeric value to a character string formatted as a binary integer--least significant byte first. I2BIN() is used with FWRITE() to convert a xClipper numeric to a standard binary form. The inverse of I2BIN() is BIN2I().

Function INT()

 INT(<nExp>) --> nInteger

INT() is a numeric function that converts a numeric value to an integer by truncating--not rounding--all digits to the right of the decimal point. INT() is useful in operations where the decimal portion of a number is not needed.

Function L2BIN()

 L2BIN(<nExp>) --> cBinaryInteger

L2BIN() is a low-level file function used with FWRITE() to write xClipper numeric values to a binary file. This function is like I2BIN() which formats a xClipper numeric to a 16-bit binary value.

L2BIN() is the inverse function of BIN2L().

Function LOG()

 LOG(<nExp>) --> nNaturalLog

LOG() is a numeric function that calculates the natural logarithm of a number and is the inverse of EXP(). The natural logarithm has a base of e which is approximately 2.7183. The LOG() function returns x in the following equation,

e**x = y

where y is the numeric expression used as the LOG() argument (i.e., LOG(y) = x). Due to mathematical rounding, the values returned by LOG() and EXP() may not agree exactly (i.e., EXP(LOG(x)) may not always equal x).

Function MAX()

 MAX(<nExp1>, <nExp2>) --> nLarger
 MAX(<dExp1>, <dExp2>) --> dLarger

MAX() is a numeric and date function that ensures the value of an expression is larger than a specified minimum. The inverse of MAX() is MIN(), which returns the lesser of two numeric or date values.

Function MIN()

 MIN(<nExp1>, <nExp2>) --> nSmaller
 MIN(<dExp1>, <dExp2>) --> dSmaller

MIN() is a numeric and date function that ensures the value of an expression is smaller than a specified minimum. The inverse of MIN() is MAX() which returns the greater of two numeric or date values.

Function MOD()

 MOD(<nDividend>, <nDivisor>) --> nRemainder

MOD() is a numeric function that emulates the dBASE III PLUS MOD() function.

MOD() is supplied as a compatibility function and therefore not recommended. It is superseded entirely by the modulus operator (%).

Function ROUND()

 ROUND(<nNumber>, <nDecimals>) --> nRounded

ROUND() is a numeric function that rounds <nNumber> to the number of places specified by <nDecimals>. Specifying a zero or negative value for <nDecimals> allows rounding of whole numbers. A negative <nDecimals> indicates the number of digits to the left of the decimal point to round. Digits between five to nine (inclusive) are rounded up. Digits below five are rounded down.

The display of the return value does not obey the DECIMALS setting unless SET FIXED is ON. With SET FIXED OFF, the display of the return value contains as many decimal digits as you specify for <nDecimals>, or zero, if <nDecimals> is less than one.

Function SQRT()

 SQRT(<nNumber>) --> nRoot

SQRT() is a numeric function used anywhere in a numeric calculation to compute a square root (e.g., in an expression that calculates standard deviation).