The built-in numeric types are integers and floats, which are equivalent to
Wrapping<i32>
and f32
respectively.
Floats are "contagious". When an arithmetic function receives at least one float argument, the return value is usually a float, even when its other arguments are integers.
Arithmetic
+
Addition.
-
Subtraction or negation.
*
Multiplication.
/
Division or reciprocation.
%
Remainder.
div-euclid
Euclidean division.
rem-euclid
Euclidean remainder.
abs
Absolute value.
sign
Sign.
Predicates
even?
Returns #t
if its argument is even.
odd?
Returns #t
if its argument is odd.
nat-int?
Returns #t
if its argument is a natural integer (>= 0).
pos-int?
Returns #t
if its argument is a positive integer (> 0).
neg-int?
Returns #t
if its argument is a negative integer (< 0).
nan?
Returns #t
if its argument is a NaN.
inf?
Returns #t
if its argument is infinite.
Comparisons
==
Numeric equality test.
<
Numeric less-than test.
<=
Numeric less-than-or-equal test.
>
Numeric greater-than test.
>=
Numeric greater-than-or-equal test.
ord
Numeric or lexicographic ordering.
min
Minimum.
max
Maximum.
clamp
Clamps a value to a numeric range.
Mathematics
round
Round-to-nearest.
floor
Round down.
ceil
Round up.
sqrt
Square root.
cbrt
Cube root.
pow
Exponentiation.
log
Logarithm.
flo-sign
Floating-point sign bit.
trunc
Returns the integer part of a float, as a float.
fract
Returns the fractional part of a float.
sin
Sine, in radians.
cos
Cosine, in radians.
tan
Tangent, in radians.
asin
Arcsine, in radians.
acos
Arccosine, in radians.
atan
Arctangent, in radians.
Bit Manipulation
bitand
Bitwise AND.
bitor
Bitwise inclusive OR.
bitxor
Bitwise exclusive OR.
bitnot
Bitwise NOT.
bitshl
Left shift.
bitshr
Logical right shift.
bitsar
Arithmetic right shift.
Randomness
rand
Generates a random number.
chance?
Returns #t
or #f
in the given ratio.
rand-pick
Randomly selects one of its arguments.
rand-weighted
Randomly selects one item from a group, with unequal probability.
rand-reseed
Restarts the random number generator from a fixed seed.