Module Decimal

module Decimal: sig .. end
Arbitrary precision real numbers
Author(s): Christoph Sticksel

type t 
Type of arbitrary precision rational numbers

Pretty-printing and String Representation


val pp_print_decimal : Format.formatter -> t -> unit
Pretty-print a rational
val pp_print_decimal_as_float : Format.formatter -> t -> unit
Pretty-print a rational as an f64 (used by compilation to Rust)
val pp_print_decimal_as_lus_real : Format.formatter -> t -> unit
Pretty-print a rational as an f64 (used by contract generation)
val pp_print_decimal_sexpr : Format.formatter -> t -> unit
Pretty-print a rational as an S-expression
val string_of_decimal : t -> string
Return a string representation of a rational
val string_of_decimal_sexpr : t -> string
Return an S-expression string representation of a rational

Conversions


val of_int : int -> t
Convert an integer to a rational
val of_big_int : Big_int.big_int -> t
Convert an arbitrary large integer to a rational
val of_num : Num.num -> t
Convert an ocaml Num to a rational
val of_string : string -> t
Convert a string in floating-point notation 1.2E3 to rational number
val to_int : t -> int
Convert a rational number to a rational

Truncates the rational number to an integer and raises the exception Failure "int_of_big_int" if the numeral cannot be represented as an integer.

val to_big_int : t -> Big_int.big_int
Convert a rational number to an arbitrary large integer
val is_int : t -> bool
Return true if decimal coincides with an integer

Constants


val zero : t
The rational number zero
val one : t
The rational number one

Arithmetic operations


val succ : t -> t
Successor
val pred : t -> t
Predecessor
val abs : t -> t
Absolute value
val neg : t -> t
Unary negation
val add : t -> t -> t
Sum
val sub : t -> t -> t
Difference
val mult : t -> t -> t
Product
val div : t -> t -> t
Quotient
val rem : t -> t -> t
Remainder

Infix operators


val (~-) : t -> t
Unary negation
val (+) : t -> t -> t
Sum
val (-) : t -> t -> t
Difference
val ( * ) : t -> t -> t
Product
val (/) : t -> t -> t
Quotient
val (mod) : t -> t -> t
Remainder

Comparison operators


val equal : t -> t -> bool
Equality
val compare : t -> t -> int
Comparison
val leq : t -> t -> bool
Less than or equal predicate
val lt : t -> t -> bool
Less than predicate
val geq : t -> t -> bool
Greater than or equal predicate
val gt : t -> t -> bool
Greater than predicate

Infix operators


val (=) : t -> t -> bool
Equality
val (<>) : t -> t -> bool
Disequality
val (<=) : t -> t -> bool
Less than or equal predicate
val (<) : t -> t -> bool
Less than predicate
val (>=) : t -> t -> bool
Greater than or equal predicate
val (>) : t -> t -> bool
Greater than predicate