package tezos-protocol-011-PtHangz2

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type 't num

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.

type n =
  1. | Natural_tag

Flag for natural numbers.

type z =
  1. | Integer_tag

Flag for relative numbers.

val zero_n : n num

Natural zero.

val one_n : n num

Natural one.

val succ_n : n num -> n num

Natural successor.

succ_n x is the same as add_n one_n.

val zero : z num

Relative zero.

val compare : 'a num -> 'a num -> int

Compare two numbers as if they were

val to_string : _ num -> string

Conversion to an OCaml string in decimal notation.

val of_string : string -> z num option

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 of_int32 : int32 -> z num

Conversion from an OCaml int32.

val to_int64 : _ num -> int64 option

Conversion to an OCaml int64, returns None on overflow.

val of_int64 : int64 -> z num

Conversion from an OCaml int64.

val to_int : _ num -> int option

Conversion to an OCaml int, returns None on overflow.

val of_int : int -> z num

Conversion from an OCaml int.

Conversion from a Zarith integer (Z.t).

Conversion to a Zarith integer (Z.t).

val add_n : n num -> n num -> n num

Addition between naturals.

val mul_n : n num -> n num -> n num

Multiplication between naturals.

val ediv_n : n num -> n num -> (n num * n num) option

Euclidean division between naturals. ediv_n n d returns None if divisor is zero, or Some (q, r) where n = d * q + r and [0 <= r < d] otherwise.

val add : _ num -> _ num -> z num

Sign agnostic addition. Use add_n when working with naturals to preserve the sign.

val sub : _ num -> _ num -> z num

Sign agnostic subtraction. Use sub_n when working with naturals to preserve the sign.

val mul : _ num -> _ num -> z num

Sign agnostic multiplication. Use mul_n when working with naturals to preserve the sign.

val ediv : _ num -> _ num -> (z num * n num) option

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 naturals to preserve the sign.

val abs : z num -> n num

Compute the absolute value of a relative, turning it into a natural.

val is_nat : z num -> n num option

Partial identity over N.

val neg : _ num -> z num

Negates a number.

val int : n num -> z num

Turns a natural into a relative, not changing its value.

val lognot : _ num -> z num

Reverses each bit in the representation of the number. Also applies to the sign.

val shift_left_n : n num -> n num -> n num option

Shifts the natural to the left of a number of bits between 0 and 256. Returns None if the amount is too high.

val shift_right_n : n num -> n num -> n num option

Shifts the natural to the right of a number of bits between 0 and 256. Returns None if the amount is too high.

val shift_left : 'a num -> n num -> 'a num option

Shifts the number to the left of a number of bits between 0 and 256. Returns None if the amount is too high.

val shift_right : 'a num -> n num -> 'a num option

Shifts the number to the right of a number of bits between 0 and 256. Returns None if the amount is too high.

val logor : 'a num -> 'a num -> 'a num

Applies a boolean or operation to each bit.

val logand : _ num -> n num -> n num

Applies a boolean and operation to each bit.

val logxor : n num -> n num -> n num

Applies a boolean xor operation to each bit.

OCaml

Innovation. Community. Security.