Skip to main content

Module nat

Module nat 

Source
Expand description

Lean’s Nat: a natural number of any size.

A number that fits in a word minus one bit is stored in the pointer bits; anything larger is a heap object holding limbs. Every function keeps that invariant, so equal numbers have equal representations. As in lean.h, arguments are borrowed and results are owned, except for the _mk conversions, which consume their argument.

Constants§

MAX_SMALL
The largest number stored in the pointer bits.

Functions§

cstr_to_nat
A literal too large for unsigned_to_nat, from its decimal digits.
float_of_nat⚠
The nearest f64.
int8_of_nat⚠
int16_of_nat⚠
int32_of_nat⚠
int64_of_nat⚠
isize_of_nat⚠
nat_add⚠
nat_dec_eq⚠
nat_dec_le⚠
nat_dec_lt⚠
nat_div⚠
Division rounding down; zero when the divisor is zero.
nat_div_exact⚠
Division of a number by one of its divisors.
nat_gcd⚠
nat_land⚠
nat_log2⚠
The position of the highest set bit; zero for zero.
nat_lor⚠
nat_lxor⚠
nat_mod⚠
Remainder; the dividend when the divisor is zero.
nat_mul⚠
nat_pow⚠
nat_powmod⚠
nat_pred⚠
nat_shiftl⚠
nat_shiftr⚠
nat_sub⚠
Truncated subtraction: zero when b is larger.
nat_succ⚠
of_u128
ordering⚠
to_decimal⚠
The decimal digits of a number.
to_u128⚠
The number as a u128, if it fits.
uint8_of_nat⚠
The number modulo the width of the result.
uint8_of_nat_mk⚠
Like the function without _mk, but consumes the argument.
uint8_to_nat
uint16_of_nat⚠
The number modulo the width of the result.
uint16_of_nat_mk⚠
Like the function without _mk, but consumes the argument.
uint16_to_nat
uint32_of_nat⚠
The number modulo the width of the result.
uint32_of_nat_mk⚠
Like the function without _mk, but consumes the argument.
uint32_to_nat
uint64_of_nat⚠
The number modulo the width of the result.
uint64_of_nat_mk⚠
Like the function without _mk, but consumes the argument.
uint64_to_nat
unsigned_to_nat
usize_of_nat⚠
The number modulo the width of the result.
usize_of_nat_mk⚠
Like the function without _mk, but consumes the argument.
usize_to_nat