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 precisionabs( 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
phase( t, period )
For positive period, the returned value is in the range [0,1).
t
(floating point): valueperiod
(floating point): folding periodphase( 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( 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 phase