Numeric Functions
This section contains the intrinsic functions that are used for working with numbers.
.fix()
Prototype
.fix
(
, <value>
) <denominator>
Return types
.nul, .inf, integer, number
Description
Returns the result of rounding a numeric value to the nearest multiple of a specified
fraction. If the second parameter is 1, then the value will be rounded to the nearest whole
number value, with values exactly between being rounded away from zero. That means that if
the value is 0.5
and the denominator is 1
, then the
return value will be 1
. If the value is -0.5
and the
denominator is 1
, then the return value will be -1
.
This function can be used to return a value to the nearest whole number as just described,
or to the nearest half, using a denominator of 2, nearest fourth, using a denominator of 4,
nearest 10th, using a denominator of 10, and so on.
Parameters
value
Type name | Result for an expression of this type in this parameter |
---|---|
.nul
| The result will be .nul |
.inf
| The result will be .inf , unless another parameter
causes the result to be .nul
|
integer
| The result will be the value of this parameter, unless another parameter
causes the value to be .nul or .inf
|
number
| The number to be rounded to the nearest fraction |
denominator
Type name | Result for an expression of this type in this parameter |
---|---|
.nul
| The result will be .nul |
.inf
| The result will be the value of the first parameter |
integer
| The denominator of the fraction to round to, for example the value 1000 will cause rounding to three decimal digits |
.ipower()
Prototype
.ipower
(
, <operand>
) <power>
Return types
.nul, .inf, integer
Description
Returns the result of raising the operand
to
power
. If either operand
or
power
is .nul
then the result is
.nul
. Otherwise, if either operand
or
power
is .inf
then the result is
.inf
. Otherwise, power
must be
non-negative. If power
is equal to zero then the result is
equal to one. If operand
is equal to one then the result is
equal to one. If operand
is equal to zero and
power
is not equal to zero then the result is zero. Otherwise
the result is operand
to the power of
power
, in the normal way.
Parameters
operand
Type name | Result for an expression of this type in this parameter |
---|---|
.nul
| The result will be .nul |
.inf
| The result will be .inf , unless another parameter
causes the result to be .nul
|
integer
| The result will be the value of this parameter raised to the power of the
second parameter, unless the second parameter causes the value to be
.nul or .inf
|
power
Type name | Result for an expression of this type in this parameter |
---|---|
.nul
| The result will be .nul |
.inf
| The result will be .inf unless the first parameter
causes it to be .nul or .inf |
integer
| The first parameter raised to the power represented by this parameter
unless the first parameter causes it to be .nul
|
.ipowermod()
Prototype
.ipowermod
(
, <operand>
, <power>
) <modulus>
Return types
.nul, .inf, integer
Description
Returns the remainder of result reached by raising the
operand
to power
and then dividing
by the modulus value. If any of the parameters is equal to .nul
then
the result is .nul
. If modulus
is
.inf
then the result is the same as .ipower(operand,
power)
. Otherwise, if either operand
or
power
is .inf
then the result is
.inf
. Barring those cases, power
must be
non-negative and modulus
must be positive. If
modulus
is equal to one then the result is zero. If
power
is equal to zero then the result is equal to one. If
operand
is equal to zero or one then the result is equal to
zero or one respectively. Otherwise the result is operand
to
the power of power
mod
modulus
, in the normal way.
Parameters
operand
Type name | Result for an expression of this type in this parameter |
---|---|
.nul
| The result will be .nul |
.inf
| The result will be .inf , unless another parameter
causes the result to be .nul
|
integer
| The result will be the value of this parameter raised to the power of the
second parameter modulus the third parameter, unless another parameter causes
the value to be .nul or .inf
|
power
Type name | Result for an expression of this type in this parameter |
---|---|
.nul
| The result will be .nul |
.inf
| The result will be .inf unless another parameter causes
it to be .nul |
integer
| The first parameter raised to the power represented by this parameter
modulus the third parameter unless another parameter causes it to be
.nul or .inf
|
modulus
Type name | Result for an expression of this type in this parameter |
---|---|
.nul
| The result will be .nul |
.inf
| The result will be the same as .ipower(operand,
power) |
integer
| The first parameter raised to the power represented by the second
parameter modulus this parameter unless another parameter causes it to be
.nul or .inf
|