Standard arithmetic functions including things like rounding, sign manipulation, and maximum/minimum functions. Phase folding operations, and a convenient form of the modulus operation on which they are based, are also provided.
roundUp( x )
x (floating point): a value.
x rounded up
roundDown( x )
x (floating point): a value
x rounded down
round( x )
x (floating point): a floating point value.
x rounded to the nearest integer
roundDecimal( x, dp )float (32-bit floating point value),
so this is only suitable for relatively low-precision values.
It's intended for truncating the number of apparent significant
figures represented by a value which you know has been obtained
by combining other values of limited precision.
For more control, see the functions in the Formats class.
x (floating point): a floating point value
dp (integer): number of decimal places (digits after the decimal point)
to retain
x but with a
limited apparent precision
roundDecimal(PI,2) = 3.14fabs( x )
x (integer): the argument whose absolute value is to be determined
abs( x )
x (floating point): the argument whose absolute value is to be determined
max( a, b )Multiple-argument maximum functions are also provided in the
Arrays and Lists packages.
a (integer): an argument.
b (integer): another argument.
a and b.
maxNaN( a, b )
a (floating point): an argument.
b (floating point): another argument.
a and b.
maxReal( a, b )Multiple-argument maximum functions are also provided in the
Arrays and Lists packages.
a (floating point): an argument
b (floating point): another argument
a and bmin( a, b )Multiple-argument minimum functions are also provided in the
Arrays and Lists packages.
a (integer): an argument.
b (integer): another argument.
a and b.
minNaN( a, b )
a (floating point): an argument.
b (floating point): another argument.
a and b.
minReal( a, b )Multiple-argument minimum functions are also provided in the
Arrays and Lists packages.
a (floating point): an argument
b (floating point): another argument
a and bmod( a, b )a/b.
This is a modulo operation, but differs from the expression
a%b in that the answer is always >=0
(as long as b is not zero).
a (floating point): dividend
b (floating point): divisor
a by bmodulo(14, 5) = 4modulo(-14, 5) = 1modulo(2.75, 0.5) = 0.25phase( t, period )For positive period, the returned value is in the range [0,1).
t (floating point): value
period (floating point): folding period
phase(7, 4) = 0.75phase(-1000.5, 2.5) = 0.8phase(-3300, 33) = 0phase( t, period, t0 )t0 corresponds to phase zero.
For positive period, the returned value is in the range [0,1).
t (floating point): value
period (floating point): folding period
t0 (floating point): reference value, corresponding to phase zero
phase(5003,100,0) = 0.03phase(5003,100,2) = 0.01phase(5003,100,4) = 0.99phase( t, period, t0, phase0 )t0 corresponds to integer phase
value, and the phase offset phase0 determines the
starting value for the phase range.
For positive period, the returned value is in the range
[phase0,phase0+1).
t (floating point): value
period (floating point): folding period
t0 (floating point): reference value, corresponding to phase zero
phase0 (floating point): offset for phase
phase(23,10,1,99) = 99.2phase(8.6125,0.2,0.0125,-0.3) = 0phase(8.6125,0.2,0.1125,-0.7) = -0.5