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 int64
nat alias nat64
float alias float64
new nat8()
new nat16()
new nat32()
new nat64()
new int8()
new int16()
new int32()
new int64()
new float32()
new float64()
== bool(a nat8, b nat8)
== bool(a nat16, b nat16)
== bool(a nat32, b nat32)
== bool(a nat64, b nat64)
== bool(a int8, b int8)
== bool(a int16, b int16)
== bool(a int32, b int32)
== bool(a int64, b int64)
== bool(a float32, b float32)
This treats all nan values as equal, since safe code can't distinguish them. However, -0 is not equal to 0.
== bool(a float64, b float64)
<=> comparison(a nat8, b nat8)
<=> comparison(a nat16, b nat16)
<=> comparison(a nat32, b nat32)
<=> comparison(a nat64, b nat64)
<=> comparison(a int8, b int8)
<=> comparison(a int16, b int16)
<=> comparison(a int32, b int32)
<=> comparison(a int64, b int64)
<=> comparison(a float32, b float32)
The order is nan, -infinity, ..., -0, +0, ..., infinity
<=> comparison(a float64, b 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)
wrap-to int8(a int64)
wrap-to int16(a int64)
wrap-to int32(a int64)
wrap-to int8(a nat64)
wrap-to int16(a nat64)
wrap-to int32(a nat64)
wrap-to int64(a nat64)
wrap-to nat8(a nat64)
wrap-to nat16(a nat64)
wrap-to nat32(a nat64)
wrap-to nat8(a int64)
wrap-to nat16(a int64)
wrap-to nat32(a int64)
wrap-to nat64(a int64)
wrap-add nat8(a nat8, b nat8)
wrap-add nat16(a nat16, b nat16)
wrap-add nat32(a nat32, b nat32)
wrap-add nat64(a nat64, b nat64)
wrap-add int8(a int8, b int8)
wrap-add int16(a int16, b int16)
wrap-add int32(a int32, b int32)
wrap-add int64(a int64, b int64)
wrap-sub nat8(a nat8, b nat8)
wrap-sub nat16(a nat16, b nat16)
wrap-sub nat32(a nat32, b nat32)
wrap-sub nat64(a nat64, b nat64)
wrap-sub int8(a int8, b int8)
wrap-sub int16(a int16, b int16)
wrap-sub int32(a int32, b int32)
wrap-sub int64(a int64, b int64)
wrap-mul nat8(a nat8, b nat8)
wrap-mul nat16(a nat16, b nat16)
wrap-mul nat32(a nat32, b nat32)
wrap-mul nat64(a nat64, b nat64)
wrap-mul int8(a int8, b int8)
wrap-mul int16(a int16, b int16)
wrap-mul int32(a int32, b int32)
wrap-mul int64(a int64, b int64)
is-even bool(a nat64)
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()
integral union
Used to store values for exceptions
unary-out-of-range record
input integral
show string(_ unary-out-of-range)
binary-out-of-range record
show string(_ binary-out-of-range)
divide-by-0 record (has private fields)
show string(_ divide-by-0)
+ 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)
div-ceil nat64(a nat64, b nat64)
Like a / b but takes the ceil instead of the floor.
% nat64(a nat64, b nat64)
Remainder of a / b. Result will be in the range 0 .. b. Throws if b == 0.
% nat32(a nat32, b nat32)
% nat64(a int64, b nat64)
This returns a nat64 since modulo always returns a non-negative number.
modulo-of-negative record (has private fields)
show string(_ modulo-of-negative)
% 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 unary-out-of-range 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)
** nat64(a nat64, b nat64)
+ float32(a float32, b float32)
Never throws.
+ float64(a float64, b float64)
- float32(a float32)
Never throws.
- float64(a float64)
- float32(a float32, b float32)
Never throws.
- float64(a float64, b float64)
* float32(a float32, b float32)
Never throws.
* float64(a float64, b float64)
/ 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 power-of-negative-number if a is negative and b is not an integer.
** float64(a float64, b float64)
power-of-negative-number record (has private fields)
show string(_ power-of-negative-number)
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 nat64)
Conversions between integral types throw on overflow or underflow. Conversions involving floats (in either direction) are approximate and never throw.
to float32(a int64)
to float32(a float64)
to float64(a nat64)
to float64(a int64)
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 nat64(a float64)
to int64(a nat64)
to nat8(a int64)
to int8(a nat64)
to int8(a int64)
to nat16(a int64)
to int16(a nat64)
to int16(a int64)
to int32(a int64)
Convert an int to 32 bits. Fail if the result would overflow.
to int32(a nat64)
clamp-sub nat64(a nat64, b nat64)
clamp-to int32(a int64)
Return the closest value. Never throws.
clamp-to int64(a nat64)
clamp-to nat8(a nat64)
clamp-to nat64(a int64)
clamp-to nat64(a float64)
clamp-add int32(a int32, b int32)
Return the closest possible value to a + b. Never throws.
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 nat64)
to nat16(a nat64)
to nat32(a nat64)
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-up nat64(a nat64, b nat64)
round-up-to nat64(a nat64, b nat64)
difference nat64(a int8, b int8)
difference nat64(a int16, b int16)
difference nat64(a int32, b int32)
difference nat64(a int64, b int64)