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 uproundDown( x )
x (floating point): a valuex rounded downround( x )
x (floating point): a floating point value.x rounded to the nearest integerroundDecimal( 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 valuedp (integer): number of decimal places (digits after the decimal point)
to retainx but with a
limited apparent precisionroundDecimal(PI,2) = 3.14f
abs( x )
x (integer): the argument whose absolute value is to be determinedabs( x )
x (floating point): the argument whose absolute value is to be determinedmax( 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 argumentb (floating point): another argumenta and b
min( 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 argumentb (floating point): another argumenta and b
mod( 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): dividendb (floating point): divisora by b
modulo(14, 5) = 4
modulo(-14, 5) = 1
modulo(2.75, 0.5) = 0.25
phase( t, period )
For positive period, the returned value is in the range [0,1).
t (floating point): valueperiod (floating point): folding periodphase(7, 4) = 0.75
phase(-1000.5, 2.5) = 0.8
phase(-3300, 33) = 0
phase( t, period, t0 )
t0 corresponds to phase zero.
For positive period, the returned value is in the range [0,1).
t (floating point): valueperiod (floating point): folding periodt0 (floating point): reference value, corresponding to phase zerophase(5003,100,0) = 0.03
phase(5003,100,2) = 0.01
phase(5003,100,4) = 0.99
phase( 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): valueperiod (floating point): folding periodt0 (floating point): reference value, corresponding to phase zerophase0 (floating point): offset for phasephase(23,10,1,99) = 99.2
phase(8.6125,0.2,0.0125,-0.3) = 0
phase(8.6125,0.2,0.1125,-0.7) = -0.5