Mavryk_raw_protocol_001_PtAtLas.Script_int
The types for arbitrary precision integers in Michelson. The type variable 't
is always n
or z
, n num
and z num
are incompatible.
This is internally a Z.t
. This module mostly adds signedness preservation guarantees.
num
is made algebraic in order to distinguish it from the other type parameters of Script_typed_ir.ty
.
val to_string : _ num -> string
Conversion to an OCaml string
in decimal notation.
Conversion from an OCaml string
. Returns None
in case of an invalid notation. Supports +
and -
sign modifiers, and 0x
, 0o
and 0b
base modifiers.
val to_int64 : _ num -> int64 option
Conversion to an OCaml int64
, returns None
on overflow.
val to_int : _ num -> int option
Conversion to an OCaml int
, returns None
on overflow.
val of_zint : Mavryk_protocol_environment_001_PtAtLas.Z.t -> z num
Conversion from a Zarith integer (Z.t
).
val to_zint : 'a num -> Mavryk_protocol_environment_001_PtAtLas.Z.t
Conversion to a Zarith integer (Z.t
).
Euclidean division of a natural. ediv_n n d
returns None
if divisor is zero, or Some (q, r)
where n = d * q + r
and [0 <= r < d]
otherwise.
Sign agnostic addition. Use add_n
when working with naturals to preserve the sign.
Sign agnostic multiplication. Use mul_n
when working with a natural to preserve the sign.
Sign agnostic euclidean division. ediv n d
returns None
if divisor is zero, or Some (q, r)
where n = d * q + r
and [0 <= r < |d|]
otherwise. Use ediv_n
when working with a natural to preserve the sign.
Reverses each bit in the representation of the number. Also applies to the sign.
Shifts the natural to the left of a number of bits between 0 and 256. Returns None
if the amount is too high.
Shifts the natural to the right of a number of bits between 0 and 256. Returns None
if the amount is too high.
Shifts the number to the left of a number of bits between 0 and 256. Returns None
if the amount is too high.
Shifts the number to the right of a number of bits between 0 and 256. Returns None
if the amount is too high.
val n_encoding :
n num Mavryk_protocol_environment_001_PtAtLas.Data_encoding.encoding
Naturals are encoded using Data_encoding.n
val z_encoding :
z num Mavryk_protocol_environment_001_PtAtLas.Data_encoding.encoding
Integers are encoded using Data_encoding.z