Library Coq.Init.Decimal
Decimal numbers
These numbers coded in base 10 will be used for parsing and printing
other Coq numeral datatypes in an human-readable way.
See the
Numeral Notation command.
We represent numbers in base 10 as lists of decimal digits,
in big-endian order (most significant digit comes first).
Unsigned integers are just lists of digits.
For instance, ten is (D1 (D0 Nil))
Nil is the number terminator. Taken alone, it behaves as zero,
but rather use D0 Nil instead, since this form will be denoted
as 0, while Nil will be printed as Nil.
For signed integers, we use two constructors Pos and Neg.
Inductive int :=
Pos (
d:
uint) |
Neg (
d:
uint).
Delimit Scope dec_uint_scope with uint.
Delimit Scope dec_int_scope with int.
This representation favors simplicity over canonicity.
For normalizing numbers, we need to remove head zero digits,
and choose our canonical representation of 0 (here
D0 Nil
for unsigned numbers and
Pos (D0 Nil) for signed numbers).
nzhead removes all head zero digits
unorm : normalization of unsigned integers
norm : normalization of signed integers
A few easy operations. For more advanced computations, use the conversions
with other Coq numeral datatypes (e.g. Z) and the operations on them.
For conversions with binary numbers, it is easier to operate
on little-endian numbers.
Successor of little-endian numbers
Doubling little-endian numbers
Pseudo-conversion functions used when declaring
Numeral Notations on uint and int.