Functions included in this section are listed below. Click a link to jump to that function.
Numeric (Arithmetic Operators)
ABS( ) Function
ACOS( ) Function
ASIN( ) Function
ATAN( ) Function
ATN2( ) Function
AVG( ) Function
BINTOC( ) Function
BITAND( ) Function
BITCLEAR( ) Function
BITLSHIFT( ) Function
BITOR( ) Function
BITRSHIFT( ) Function
BITSET( ) Function
BITTEST( ) Function
BITXOR( ) Function
CEILING( ) Function
COS( ) Function
COUNT( ) Function
DTOR( ) Function
EXP( ) Function
FLOOR( ) Function
FV( ) Function
INT( ) Function
LOG( ) Function
LOG10( ) Function
MAX( ) Function
MIN( ) Function
MOD( ) Function
MTON( ) Function
NTOM( ) Function
PAYMENT( ) Function
PI( ) Function
PV( ) Function
RAND( ) Function
RECCOUNT( ) Function
RECNO( ) Function
ROUND( ) Function
RTOD( ) Function
SIGN( ) Function
SIN( ) Function
SQRT( ) Function
SUM( ) Function
TAN( ) Function
VAL( ) Function
- Highest
- Parentheses - Override the precedence rules so that you can specify the order of the operations
- Exponentiation
- Unary -/+
- Exponentiation
- Modulus
- Multiplication and division
- Addition, subtraction, and string concatenation
- Relational operators (=, <, >, et.)
- Unary .NOT.
- Logical operators (.AND. and .OR.)
- 4 * (8 - 2^3 * (3 -1))
- 4 * (8 - 2^3 *2)
- 4 * (8-8*2)
- 4 * (8-16)
- 4 * (-8)
- -32
Purpose | Returns the absolute value of the specified numeric expression | ||||||||
Syntax | ABS(<expN>) | ||||||||
Returns | Numeric | ||||||||
Parameter | <expN> is the numeric expression whose absolute value is returned by ABS( ) | ||||||||
Examples |
|
Purpose | This trigonometric function returns the arc cosine in radians. | ||||
Syntax | ACOS(<expN>) | ||||
Returns | Numeric | ||||
Parameter | <expN> The arc cosine of <expN> is returned by ACOS( ). The value of <expN> can range from +1 through -1. The value returned by ACOS( ) ranges from 0 through pi ( 3.141592). The number of decimal places ACOS( ) returns is determined by SET DECIMALS.
Use RTOD( ) to convert radians to degrees. |
||||
Examples |
|
Purpose | This trigonometric function returns in radians the arc sine of the numeric expression <expN> | ||||
Syntax | ASIN(<expN>) | ||||
Returns | Numeric | ||||
Parameters | <expN> The value of <expN> can range from +1 through -1, and the value returned by ASIN( ) can range from -pi/2 through +pi/2 ( -1.57079 to 1.57079). The number of decimal places in the display of the result can be specified with SET DECIMALS.
Use RTOD( ) to convert radians to degrees. |
||||
Example |
|
Purpose | This trigonometric function returns in radians the arc tangent of a numeric expression. | ||||
Syntax | ATAN(<expN>) | ||||
Returns | Numeric | ||||
Parameter | <expN> ATAN( ) returns the arc tangent of the numeric expression <expN>. <expN> can be any value; the value returned by ATAN( ) can range from -pi/2 through +pi/2 ( -1.57079 to 1.57079). The number of decimal places displayed in the value returned by ATAN( ) is determined by SET DECIMALS.
The numeric value returned by ATAN( ) is in radians. Use RTOD( ) to convert this value to degrees. |
||||
Examples |
|
Purpose | This trigonometric function returns the arc tangent angle in all four quadrants from specified sine and cosine values. | ||||
Syntax | ATN2(<expN1>, <expN2>) | ||||
Returns | Numeric | ||||
Parameters | <expN1> The coordinate y
<expN2> The coordinate x The value of <expN1>/<expN2> must be between -pi and +pi. The value returned by ATN2( ) can be converted to degrees with RTOD( ). The number of decimal places in the display of the result can be specified with SET DECIMALS. |
||||
Remarks | In ATN2( ) you specify a set of x and y coordinates. In ATAN( ) you specify a tangent value. | ||||
Example |
|
Purpose | Computes the arithmetic mean of <expN>. | ||
Syntax | AVG(<expN>) | ||
Returns | Numeric | ||
Parameters | <expN> | ||
Remarks | The <expN> in AVG( ) may be a number, or a numeric expression, memory variable, or a field. | ||
Example |
|
Purpose | Converts an integer value to a binary character representation. | ||||||||
Syntax | BINTOC(<expN1> [, <expN2>]) | ||||||||
Returns | Character | ||||||||
Parameters | <expN1> Specifies the integer value to convert.
<expN2> Specifies the length in characters of the returned character string. <expN2> also determines the value you can specify for <expN1>. The following table lists the permissible values for <expN2> and the corresponding range of values for <expN2>.
If <expN2> is omitted, BINTOC() returns a character string composed of four characters. |
||||||||
Remarks | BINTOC() lets you convert the value in the numeric field to a single character representation. | ||||||||
Example |
|
Purpose | Returns the result of a bitwise AND operation performed on two numeric values. | |||||||||||||||
Syntax | BITAND(<expN1>, <expN2>) | |||||||||||||||
Returns | Numeric | |||||||||||||||
Parameters | <expN1>, <expN2> Specifies the numeric values on which the bitwise AND operation is performed. If <expN1> and <expN2> are not integers, they are converted to integers before the bitwise AND operation is performed. | |||||||||||||||
Remarks |
BITAND() compares each bit in <expN1> to the corresponding bit in <expN2>. If the bits in <expN1> and <expN2> are both 1, the corresponding result bit is set to 1; otherwise, the corresponding result bit is set to 0. The following table shows the result of a bitwise AND operation on corresponding <expN1> and <expN2> bits.
|
|||||||||||||||
Example |
|
Purpose | Clears a specified bit (sets it to 0) in a numeric value and returns the resulting value. | ||||
Syntax | BITCLEAR(<expN1>, <expN2>) | ||||
Returns | Numeric | ||||
Parameters | <expN1> Specifies the numeric value in which a bit is cleared. If <expN1> is not an integer, it is converted to an integer before its bit is set.
<expN2> Specifies the bit position in <expN1> that is cleared. <expN2> can range from 0 to 31; 0 is the rightmost bit. |
||||
Example |
|
Purpose | Returns the result of shifting the bits of a numeric value to the left a specified number of positions. | ||||
Syntax | BITLSHIFT(<expN1>, <expN2>) | ||||
Returns | Numeric | ||||
Parameters | <expN1> Specifies the numeric value whose bits are shifted to the left. If <expN1> is not an integer, it is converted to an integer before its bits are shifted.
<expN2> Specifies the number of bit positions to shift. If <expN2> is not an integer, it is converted to an integer. |
||||
Example |
|
Purpose | Returns the result of a bitwise inclusive OR operation performed on two numeric values. | |||||||||||||||
Syntax | BITOR(<expN1>, <expN2>) | |||||||||||||||
Returns | Numeric | |||||||||||||||
Parameters | <expN1>, <expN2> Specifies the numeric values on which the bitwise inclusive OR operation is performed. If <expN1> and <expN2> are not integers, they are converted to integers before the bitwise inclusive OR operation is performed. | |||||||||||||||
Remarks |
BITOR( ) compares each bit in <expN1> to the corresponding bit in <expN2>. If either bit in <expN1> or <expN2> is 1, the corresponding result bit is set to 1; otherwise, the corresponding result bit is set to 0. The following table shows the result of an inclusive OR operation on corresponding <expN1> and <expN2> bits:
|
|||||||||||||||
Example |
|
Purpose | Returns the result of shifting the bits of a numeric value to the right a specified number of positions. | ||||
Syntax | BITRSHIFT(<expN1>, <expN2>) | ||||
Returns | Numeric | ||||
Parameters | <expN1> Specifies the numeric value whose bits are shifted to the right. If <expN1> is not an integer, it is converted to an integer before its bits are shifted.
<expN2> Specifies the number of bit positions to shift. If <expN2> is not an integer, it is converted to an integer. |
||||
Example |
|
Purpose | Sets the bit to 1 in a numeric value and returns the resulting value. | ||||
Syntax | BITSET(<expN1>, <expN2>) | ||||
Returns | Numeric | ||||
Parameters | <expN1> Specifies the numeric value in which a bit is set. If <expN1> is not an integer, it is converted to an integer before its bit is set.
<expN2> Specifies the bit position in <expN1> that is set to 1. <expN2> can range from 0 to 31; 0 is the rightmost bit. |
||||
Example |
|
Purpose | Returns true (.T.) if a specified bit in a numeric value is set to 1; otherwise, returns false (.F.). | ||||
Syntax | BITTEST(<expN1>, <expN2>) | ||||
Returns | Logical | ||||
Parameters | <expN1> Specifies the numeric value in which a bit is checked. If <expN1> is not an integer, it is converted to an integer before its bit is checked.
<expN2> Specifies the bit position in <expN1> that is checked. <expN2> can range from 0 to 31; 0 is the rightmost bit. |
||||
Example |
|
Purpose | Returns the result of a bitwise exclusive OR operation performed on two numeric values. | |||||||||||||||
Syntax | BITXOR(<expN1>, <expN2>) | |||||||||||||||
Returns | Numeric | |||||||||||||||
Parameters | <expN1>,<expN2> Specifies the numeric values on which the bitwise exclusive OR operation is performed. If <expN1> and <expN2> are not integers, they are converted to integers before the bitwise exclusive OR operation is performed. | |||||||||||||||
Remarks |
BITXOR( ) compares each bit in <expN1> to the corresponding bit in <expN2>. If one bit is 0 and the other bit is 1, the corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0. The following table shows the result of an exclusive OR operation on corresponding <expN1> and <expN2> bits:
|
|||||||||||||||
Example |
|
Purpose | Returns the nearest integer that is greater than or equal to the specified numeric expression. | ||||
Syntax | CEILING(<expN>) | ||||
Returns | Numeric | ||||
Parameter | <expN> Include a numeric expression <expN> in CEILING( ). <expN> may be a number, or a numeric expression, memory variable, array element or database field. | ||||
Remarks | CEILING() returns the nearest integer that is greater than or equal to a numeric expression. This function rounds all positive numbers with a fractional portion up to the next highest integer. CEILING() returns the integer portion of a negative number with a fractional portion. | ||||
Examples |
|
Purpose | Returns the cosine of a numeric expression | ||||||
Syntax | COS(<expN>) | ||||||
Returns | Numeric | ||||||
Parameter | <expN> COS( ) returns the cosine of <expN>.
<expN> can be any value, and the value returned by COS( ) ranges between -1 and 1. <expN> is given in radians. To convert an angle from degrees to radians, use DTOR( ). The number of decimal places returned by COS( ) can be specified with SET DECIMALS. |
||||||
Examples |
|
Purpose | Counts table records. | ||
Syntax | COUNT([<expr>]) | ||
Parameters | <expr> Specifies an optional expression to count. <expr> can be a number, a numeric expression, a variable, a date, or a field. | ||
Remarks | COUNT() counts the records. | ||
Example |
|
Purpose |
Converts degrees to radians. |
||||
Syntax | DTOR(<expN>) | ||||
Returns | Numeric | ||||
Parameters | <expN> Specifies the numeric expression whose value you want to convert to radians. An angle expressed in a degree:minute:second format should be converted to its decimal equivalent. | ||||
Remarks | DTOR( ) converts the value of a numeric expression given in degrees to an equivalent value in radians. DTOR( ) is useful for working with the other trigonometric functions: ACOS( ), ASIN( ), COS( ), SIN( ), TAN( ). Use RTOD( ) to convert radians to degrees. | ||||
Example |
|
Purpose | Returns the value of e^x where x is a specified numeric expression. | ||||
Syntax | EXP(<expN>) | ||||
Returns | Numeric | ||||
Parameter | <expN> The numeric expression <expN> is the exponent, x, in the exponential equation e^x. | ||||
Remarks | The mathematical function EXP( ) returns the value of e^x where x is a numeric expression.
The value of e, the base of natural logarithms, is approximately 2.71828. The number of decimal places displayed by EXP( ) is specified with SET DECIMALS |
||||
Examples |
|
Purpose | Returns the nearest integer that is less than or equal to the specified numeric expression. | ||||
Syntax | FLOOR(<expN>) | ||||
Returns | Numeric | ||||
Parameter | <expN> FLOOR( ) returns the nearest integer that is less than or equal to <expN>. | ||||
Remarks | FLOOR( ) rounds a positive number with a fractional portion down to the integer portion of the number, and rounds a negative number with a fractional portion down to the next lowest integer. | ||||
Examples |
|
Purpose | Returns the future value of an investment.
FV( ) computes the future value of a series of constant periodic payments earning fixed compound interest. The future value is the total of all payments and the interest. |
||||||||
Syntax | FV(<expN1>, <expN2>, <expN3>) | ||||||||
Returns | Numeric | ||||||||
Parameter | <expN1> The equal periodic payment(can be negative or positive). FV( ) assumes that the periodic payments are made at the end of each period.
<expN2> The periodic interest rate. If the interest rate is annual but the periodic payments <expN1> are made monthly, divide the annual interest rate by 12. <expN3> The number of periods payments are made. |
||||||||
Examples |
|
Purpose | Evaluates a numeric expression and returns the integer portion of the expression. | ||||
Syntax | INT(<expN>) | ||||
Returns | Numeric | ||||
Parameter | <expN> INT( ) returns the integer portion of the numeric expression <expN>. | ||||
Examples |
|
Purpose | The mathematical function LOG( ) returns the natural logarithm of a numeric expression. The base for the natural logarithm is the constant e. The number of decimal places returned in the result is specified with SET DECIMALS | ||||
Syntax | LOG(<expN>) | ||||
Returns | Numeric | ||||
Parameter | <expN> LOG( ) returns the value of x in the equation ex = <expN>. The numeric expression <expN> must be greater than 0. | ||||
Examples |
|
Purpose | Returns the common logarithm (base 10) of the specified numeric expression. The mathematical function LOG10( ) returns the common logarithm of a numeric expression. The base for the common logarithm is 10. The number of decimal places returned in the result is specified with SET DECIMALS | ||||
Syntax | LOG10(<expN>) | ||||
Returns | Numeric | ||||
Parameter | <expN> LOG10( ) returns the value of x in the equation 10^x = <expN>. The numeric expression <expN> must be greater than 0. | ||||
Examples |
|
This function is defined in String Functions.
This function is defined in String Functions.
Purpose | Returns the remainder obtained by dividing a numeric expression by another numeric expression.
MOD( ) and the % operator return identical results. |
||||
Syntax | MOD(<expN1>, <expN2>) | ||||
Returns | Numeric | ||||
Parameter | <expN1> is the dividend. The number of decimal places in <expN1> determines the number of decimals places in the result.
<expN2> is the divisor. A positive number is returned if <expN2> is positive, and a negative number is returned if <expN2> is negative. |
||||
Examples |
|
Purpose | Returns a Numeric value from a Currency expression. | ||
Syntax | MTON(<expM1>) | ||
Returns | Numeric | ||
Parameter | <expM1> Specifies a Currency expression whose value MTON( ) returns. <expM1> must evaluate to a valid Currency value or Visual FoxPro generates an error. Currency values are created by placing a dollar sign ($) prefix immediately before a Numeric value. | ||
Remarks | MTON( ) returns a Numeric value with four decimal places. Currency values are not used in TAM. | ||
Example |
|
Purpose | Returns a Currency value with four decimal places from a numeric expression. | ||||
Syntax | NTOM(<expN>) | ||||
Returns | Currency | ||||
Parameter | <expN> Specifies a numeric expression whose Currency value NTOM( ) returns. If <expN> has more than four decimal places, it is rounded to four decimal places. If <expN> has less than four decimals places, it is padded with zeros until four decimal places are created. | ||||
Example |
|
Purpose | Returns the amount of each periodic payment on a fixed-interest loan. | ||||||||
Syntax | PAYMENT(<expN1>, <expN2>, <expN3>) | ||||||||
Returns | Numeric | ||||||||
Parameter | <expN1> <expN1> is the beginning principal of the loan.
<expN2> The fixed interest rate per period is <expN2>. If monthly payments are made on the loan but the interest rate is annual, divide the annual interest rate by 12. <expN3> The total number of payments to be made on the loan is <expN3>. |
||||||||
Examples |
|
Purpose | Returns the numeric constant pi.
This mathematical function returns the numeric constant pi (3.141592), the ratio of the circumference of a circle to its diameter. The number of decimal places displayed in the value returned by PI( ) is determined by SET DECIMALS |
||||
Syntax | PI( ) | ||||
Returns | Numeric | ||||
Examples |
|
Purpose | Returns the present value of an investment.
The present value of an investment is computed as the value of the investment based on a series of equal periodic payments at a constant periodic interest rate. |
||||
Syntax | PV(<expN1>, <expN2>, <expN3>) | ||||
Returns | Numeric | ||||
Parameter | <expN1> The periodic payment is specified by <expN1>. It can evaluate to a positive or negative number. PV( ) assumes that the payments are made at the end of each period.
<expN2> The periodic interest rate is specified by <expN2>. If the interest rate of an investment is annual and the payments are made monthly, divide the annual interest rate by 12. <expN3> The total number of payments is specified by <expN3>. |
||||
Examples |
|
Purpose | Returns a random number between 0 and 1.
RAND( ) returns a random number between 0 and 1. A seed value of 100001 is automatically used if <expN> is omitted in the first RAND( ) function you issue. You can restore the default at any time with RAND(100001). |
||||
Syntax | RAND([<expN>]) | ||||
Returns | Numeric | ||||
Parameter | <expN> The seed value
<expN> lets you to specify the seed value to use with the function. Using the same positive value for <expN> in the first RAND( ) function you issue, and no <expN> in subsequent RAND( ) functions, always returns the same sequence of random numbers .If <expN> is negative in the first RAND( ) function you issue, a seed value is created from the system clock. To achieve the most random series of numbers, use RAND( ) initially with a negative argument and subsequent RAND( ) functions without an argument. |
||||
Examples |
|
Purpose | Returns the number of records in the current or specified table. |
Syntax | RECCOUNT([nWorkArea | cTableAlias]) |
Returns | Numeric |
Parameters | nWorkArea Specifies the work area number for a table open in another work area. RECCOUNT() returns 0 if a table isn't open in the work area you specify.
cTableAlias Specifies the table alias for a table open in another work area. |
Remarks | The value RECCOUNT( ) returns isn't affected by SET DELETED and SET FILTER. RECCOUNT( ) without the optional arguments nWorkArea or cTableAlias returns the number of records in the table in the currently selected work area. |
Purpose | Returns the current record number in the current or specified table/.DBF.
The record pointer is positioned on the current record. RECNO( ) returns a value that is one greater than the number of records in the file if the record pointer is positioned beyond the last record in the file. RECNO( ) returns 1 if the record pointer is positioned before the first record in the file. If the table/.DBF has no records, RECNO( ) returns 1 and EOF( ) returns true (.T.). |
||
Syntax | RECNO([<expN> | <expC>]) | ||
Returns | Numeric | ||
Parameter |
|
Purpose | Return a numeric expression rounded to a specified number of decimal places. | ||||
Syntax | ROUND(<expN1>, <expN2>) | ||||
Returns | Numeric | ||||
Parameter | <expN1>
<expN1> is the numeric expression whose value is to be rounded. <expN2> <expN2> is the number of decimal places to round <expN1> to. If <expN2> is negative, ROUND( ) returns a whole number containing <expN2> zeros to the left of the decimal point. For example, if <expN2> is -2 the first and second digits to the left of the decimal point in the value are zero. |
||||
Examples |
|
Purpose | Converts a numeric expression that represents radians to an equivalent value in degrees.
RTOD( ) converts a numeric expression given in radians to an equivalent value in degrees. RTOD( ) is useful when working with FoxPro trigonometric functions such as COS( ), SIN( ), TAN( ) and so on. Use DTOR( ) to convert degrees to radians |
||||
Syntax | RTOD(<expN>) | ||||
Returns | Numeric | ||||
Parameter | <expN> is the numeric expression representing radians to be converted to degrees. | ||||
Examples |
|
Purpose | Returns a numeric value of 1, -1 or 0 depending on whether the specified numeric expression evaluates to a positive, negative, or 0 value. SIGN( ) returns a numeric value of 1, -1 or 0 depending on the sign of a numeric expression. | ||||||
Syntax | SIGN(<expN>) | ||||||
Returns | Numeric | ||||||
Parameter | <expN> A 1, -1 or 0 is returned by SIGN( ). If <expN> is positive, SIGN returns 1. If <expN> is negative, -1 is returned. If <expN> is 0, SIGN returns 0. | ||||||
Examples |
|
Purpose | Returns the sine of a numeric expression. | ||||
Syntax | SIN(<expN>) | ||||
Returns | Numeric | ||||
Parameter | <expN>
SIN( ) returns the sine of <expN>. The numeric expression <expN> may assume any value, and the value returned by SIN( ) will range between -1 and 1. <expN> is given in radians. To convert an angle from degrees to radians, use DTOR( ). The number of decimal places returned by SIN( ) may be specified with SET DECIMALS. |
||||
Examples |
|
Purpose | Returns the square root of the specified numeric expression. The number of decimal places in the value returned by SQRT( ) is the larger of the current decimal place setting and the number of decimal places contained in <expN>. The current decimal place setting is specified with SET DECIMALS | ||||
Syntax | SQRT(<expN>) | ||||
Returns | Numeric | ||||
Parameter | <expN>
Specify the numeric expression to be evaluated by SQRT( ) with <expN> . <expN> must be non-negative (zero or greater) |
||||
Examples |
|
Purpose | Total the values of <expN>. | ||
Syntax | SUM(<expN>) | ||
Returns | Numeric | ||
Parameter | <expN> | ||
Remarks | The <expN> in SUM( ) may be a number, or a numeric expression, memory variable, or a field. | ||
Examples |
|
Purpose | This trigonometric function returns the tangent of an angle. | ||||
Syntax | TAN(<expN>) | ||||
Returns | Numeric | ||||
Parameter | <expN>
TAN( ) returns the tangent of the angle specified with <expN>, which is given in radians. To convert an angle from degrees to radians, use DTOR( ). The number of decimal places returned by TAN( ) can be specified with SET DECIMALS. |
||||
Examples |
|
Purpose | Returns a numeric expression from a specified character expression composed of numbers.
VAL( ) returns a numeric value that corresponds to the value of the digits contained in a character expression. VAL( ) processes the numbers in the character expression from left to right until a non-numeric character is encountered (leading blanks are ignored). VAL( ) returns 0 if the first character of the character expression isn't a number |
||||
Syntax | VAL(<expC>) | ||||
Returns | Numeric | ||||
Parameter | <expC>
Specify a character expression composed of eight numbers with <expC>. |
||||
Examples |
|