Math Functions¶
Abs¶
Description
Returns the absolute value of a number.
Syntax
Arguments
- Number
- Any valid numeric expression. If number contains Null, Null is returned; if it is an uninitialized variable, zero is returned.
Exp¶
Description
Returns 'e' raised to the 'n'th power, where e = 2.71828183.
Syntax
Arguments
- number
- The power to raise 'e' to.
Fix¶
Description
Returns the integer portion of a number.
Syntax
Arguments
- expression
- A numeric expression whose integer portion is returned.
- If the expression is negative, the Fix function will return the first negative number that is greater than or equal to the expression.
Int¶
Description
Returns the integer portion of a number.
Syntax
Arguments
- expression
- A numeric expression whose integer portion is returned. If the expression is negative, the Int function will return the first negative number that is less than or equal to the expression.
Log¶
Description
Returns the logarithm of a number to a specified base.
Syntax
Arguments
- number
- A numeric value that must be greater than 0.
- base
- Optional. This is the base to use to calculate the logarithm of a number. If this parameter is omitted, the Log function will use a base of 10.
Rnd¶
Description
Returns a random number. The Rnd function returns a value less than 1 but greater than or equal to 0.
Syntax
Arguments
- number
- Optional and can be any valid numeric expression.
| If number is | Rnd generates |
|---|---|
| Less than zero | The same number every time, using number as the seed. |
| Greater than zero | The next random number in the sequence. |
| Equal to zero | The most recently generated number. |
| Not supplied | The next random number in the sequence. |
Round¶
Description
Returns a number rounded to a specified number of digits.
Syntax
Arguments
- number
- The number to round.
- digits
- The number of digits to round the number to.
Example
' VBScript uses banker's rounding: exact halves go to
' the nearest EVEN number, so 2.5 rounds down and 3.5
' rounds up. This surprises people reconciling totals
' against an ERP that rounds half away from zero.
Round(%UnitPrice * %Qty, 2) ' 35.00 x 10 returns 350
Round(2.5) ' Returns 2
Round(3.5) ' Returns 4
Sgn¶
Description
Returns the sign of a number (represented as an integer).
Syntax
Arguments
- number
- The number to return the sign for.
- If number is greater than zero, the Sgn function will return 1.
- If number is equal to zero, the Sgn function will return 0.
- If number is less than zero, the Sng function will return -1.
Sqr¶
Description
Returns the square root of a number.
Syntax
Arguments
- number
- Any valid numeric expression greater than or equal to 0.