keen/number

Source
This is a standard module and does not need to be explicitly imported.
See also 'keen/math/math'
nat8 builtin
8-bit natural number. An unsigned integer in the range 0 through 255.
nat16 builtin
16-bit natural number. An unsigned integer in the range 0 through 65_535.
nat32 builtin
32-bit natural number. An unsigned integer in the range 0 through 4_294_967_295 (4 billion).
nat64 builtin
64-bit natural number. An unsigned integer in the range 0 through 18_446_744_073_709_551_615 (18 quintillion).
int8 builtin
8-bit signed integer. In the range -128 through 127.
int16 builtin
16-bit signed integer. In the range -32_768 through 32_767.
int32 builtin
32-bit signed integer. In the range -2_147_483_648 through 2_147_483_647 (-2 billion through 2 billion).
int64 builtin
64-bit signed integer, In the range 9_223_372_036_854_775_808 through 9_223_372_036_854_775_807 (-9 quintillion through 9 quintillion).
float32 builtin
32-bit IEEE floating point number.
float64 builtin
64-bit IEEE floating point number.
int alias int32
nat alias nat32
float alias float64
new nat8()
new nat16()
new nat32()
new nat64()
new int8()
new int16()
new int32()
new int64()
new float32()
new float64()
float-equal bool(a float32, b float32)
IEEE equality: Treats '-0' and '0' as equal and nan as not equal to itself.
float-equal bool(a float64, b float64)
IEEE equality: Treats '-0' and '0' as equal and nan as not equal to itself.
float-less bool(a float32, b float32)
IEEE less-than: Treats '-0' and '0' as equal and always compares false when some operand is nan.
float-less bool(a float64, b float64)
is-even bool(a nat64)
is-even bool(a int64)
min-value int8()
min-value int16()
min-value int32()
min-value int64()
max-value int8()
max-value int16()
max-value int32()
max-value int64()
max-value nat8()
max-value nat16()
max-value nat32()
max-value nat64()
+ nat8(a nat8, b nat8)

Throws if the result would overflow.

"Overflow" means: be greater than the maximum possible value.

+ nat16(a nat16, b nat16)
+ nat32(a nat32, b nat32)
+ nat64(a nat64, b nat64)
- nat8(a nat8, b nat8)
Throws if the result would be negative.
- nat16(a nat16, b nat16)
- nat32(a nat32, b nat32)
- nat64(a nat64, b nat64)
* nat8(a nat8, b nat8)
Throws if the result would overflow.
* nat16(a nat16, b nat16)
* nat32(a nat32, b nat32)
* nat64(a nat64, b nat64)
/ nat8(a nat8, b nat8)
Flooring division of a divided by b. Throws if b == 0.
/ nat16(a nat16, b nat16)
/ nat32(a nat32, b nat32)
/ nat64(a nat64, b nat64)
% nat8(a nat8, b nat8)
Remainder of a / b. Result will be in the range 0 .. b. Throws if b == 0.
% nat16(a nat16, b nat16)
% nat32(a nat32, b nat32)
% nat32(a nat64, b nat32)
% nat64(a nat64, b nat64)
% nat64(a int64, b nat64)
This returns a nat64 since modulo always returns a non-negative number.
% float32(a float32, b float32)
% float64(a float64, b float64)
is-multiple-of bool(a nat64, b nat64)
true if b * x == a for some 'x'.
round-down-to-multiple-of nat64(a nat64, b nat64)
+ int8(a int8, b int8)

Throws arithmetic-error if the result would overflow.

"Overflow" means: Be less than the least possible value or greater than the greatest possible value.

+ int16(a int16, b int16)
+ int32(a int32, b int32)
+ int64(a int64, b int64)
- int8(a int8, b int8)
- int16(a int16, b int16)
- int32(a int32, b int32)
- int64(a int64, b int64)
* int8(a int8, b int8)
* int16(a int16, b int16)
* int32(a int32, b int32)
* int64(a int64, b int64)
- int8(a int8)

Negates a number. Same as a * -1.

Throws if a is min-value.

- int16(a int16)
- int32(a int32)
- int64(a int64)
- int8(a nat8)
- int16(a nat16)
- int32(a nat32)
- int64(a nat64)
/ int8(a int8, b int8)
Flooring division. Throws if b == 0. Throws if the result would overflow, which only happens if a is min-value and b is -1.
/ int16(a int16, b int16)
/ int32(a int32, b int32)
/ int64(a int64, b int64)
abs nat8(a int8)
Absolute value. For an integer type, throws for min-value.
abs nat16(a int16)
abs nat32(a int32)
abs nat64(a int64)
abs float32(a float32)
abs float64(a float64)
** int8(a int8, b nat8)
** int16(a int16, b nat16)
** int32(a int32, b nat32)
** int64(a int32, b nat64)
** nat8(a nat8, b nat8)
** nat16(a nat16, b nat16)
** nat32(a nat32, b nat32)
** nat64(a nat64, b nat64)
+ float32(a float32, b float32)
+ float64(a float64, b float64)
- float32(a float32)
- float64(a float64)
- float32(a float32, b float32)
- float64(a float64, b float64)
* float32(a float32, b float32)
* float64(a float64, b float64)
unsafe-add float32(a float32, b float32) unsafe
Returns nan for infinity + -infinity
unsafe-add float64(a float64, b float64) unsafe
unsafe-sub float32(a float32, b float32) unsafe
unsafe-sub float64(a float64, b float64) unsafe
unsafe-mul float32(a float32, b float32) unsafe
Returns nan for infinity * 0
unsafe-mul float64(a float64, b float64) unsafe
unsafe-div float32(a float32, b float32) unsafe
Divide two floats. Undefined behavior if b == 0.
unsafe-div float64(a float64, b float64) unsafe
/ float32(a float32, b float32)
Throws if b == 0.
/ float64(a float64, b float64)
** float32(a float32, b float32)
a to the power of b. Throws arithmetic-error if a is negative and b is not an integer.
** float64(a float64, b float64)
nan float32() unsafe
Not-a-Number value. 'unsafe' because Keen generally throws exceptions instead of returning NaN.
nan float64() unsafe
infinity float32()
infinity float64()
to float32(a float64)
to float32(a int8)
to float32(a int16)
to float32(a int32)
to float32(a int64)
to float32(a nat8)
to float32(a nat16)
to float32(a nat32)
to float32(a nat64)
to float64(a int8)
to float64(a int16)
to float64(a int32)
to float64(a int64)
to float64(a nat8)
to float64(a nat16)
to float64(a nat32)
to float64(a nat64)
to nat8(a float64)
to nat16(a float64)
to nat32(a float64)
to nat64(a float64)
to int8(a float64)
to int16(a float64)
to int32(a float64)
to int64(a float64)
round float32(a float32)
round float64(a float64)
round-down float32(a float32)
floor
round-down float64(a float64)
round-up float32(a float32)
ceiling
round-up float64(a float64)
to int64(a nat64)
to nat8(a int8)
to nat8(a int64)
to int8(a nat8)
to int8(a nat64)
to int8(a int32)
to int8(a int64)
to nat16(a int16)
to nat16(a int64)
to int16(a nat16)
to int16(a nat32)
to int16(a nat64)
to int16(a int32)
to int16(a int64)
to nat32(a int32)
to nat32(a int64)
to int32(a int64)
Convert an int to 32 bits. Fail if the result would overflow.
to int32(a nat32)
to int32(a nat64)
clamp-to int8(a int32)
Return the closest value. Never throws.
clamp-to int16(a int32)
clamp-to int32(a int64)
clamp-to int8(a nat8)
clamp-to int16(a nat16)
clamp-to int32(a nat32)
clamp-to int64(a nat64)
clamp-to nat8(a nat64)
clamp-to nat16(a nat64)
clamp-to nat32(a nat64)
clamp-to nat32(a int32)
clamp-to nat64(a int64)
to nat64(a int64)
Throws if the result would not have the same value as the input (due to overflow or underflow).
to nat8(a nat16)
to nat8(a nat32)
to nat8(a nat64)
to nat16(a nat32)
to nat16(a nat64)
to nat32(a nat64)
truncate-to int8(a float32)
truncate-to int16(a float32)
truncate-to int32(a float32)
truncate-to int64(a float32)
truncate-to int8(a float64)
truncate-to int16(a float64)
truncate-to int32(a float64)
truncate-to int64(a float64)
bits-of nat64(a float64)
bits-of nat32(a float32)
from-bits float32(bits nat32)
from-bits float64(bits nat64)
divide-and-round int8(a int8, b int8)
divide-and-round int16(a int16, b int16)
divide-and-round int32(a int32, b int32)
divide-and-round int64(a int64, b int64)
divide-and-round nat8(a nat8, b nat8)
divide-and-round nat16(a nat16, b nat16)
divide-and-round nat32(a nat32, b nat32)
divide-and-round nat64(a nat64, b nat64)
divide-and-round-down int8(a int8, b int8)
Rounds towards -infinity
divide-and-round-down int16(a int16, b int16)
divide-and-round-down int32(a int32, b int32)
divide-and-round-down int64(a int64, b int64)
divide-and-round-up int8(a int8, b int8)
Rounds towards +infinity
divide-and-round-up int16(a int16, b int16)
divide-and-round-up int32(a int32, b int32)
divide-and-round-up int64(a int64, b int64)
divide-and-round-up nat8(a nat8, b nat8)
divide-and-round-up nat16(a nat16, b nat16)
divide-and-round-up nat32(a nat32, b nat32)
divide-and-round-up nat64(a nat64, b nat64)
round-up-to nat64(a nat64, b nat64)
difference nat32(a int8, b int8)
difference nat32(a int16, b int16)
difference nat32(a int32, b int32)
difference nat32(a int64, b int64)
difference nat32(a nat64, b nat64)
saturating-add nat8(a nat8, b nat8)
saturating-add nat16(a nat16, b nat16)
saturating-add nat32(a nat32, b nat32)
saturating-add nat64(a nat64, b nat64)
saturating-subtract nat8(a nat8, b nat8)
saturating-subtract nat16(a nat16, b nat16)
saturating-subtract nat32(a nat32, b nat32)
saturating-subtract nat64(a nat64, b nat64)
saturating-multiply nat8(a nat8, b nat8)
saturating-multiply nat16(a nat16, b nat16)
saturating-multiply nat32(a nat32, b nat32)
saturating-multiply nat64(a nat64, b nat64)
some bool(a nat8, f bool mut(nat8))
some-reverse bool(a nat8, f bool mut(nat8))
some bool(a nat16, f bool mut(nat16))
some-reverse bool(a nat16, f bool mut(nat16))
some bool(a nat32, f bool mut(nat32))
some-reverse bool(a nat32, f bool mut(nat32))
size nat32(a nat8)
Assists with treating a number as a collection
size nat32(a nat16)
size nat32(a nat32)