module Number:sig..end
exception InvalidConstantLiteral of int * string
typeint_value =BigInt.t
type int_literal_kind =
| |
ILitUnk |
| |
ILitDec |
| |
ILitHex |
| |
ILitOct |
| |
ILitBin |
type int_constant = {
|
il_kind : |
|
il_int : |
}
type real_value = private {
|
rv_sig : |
|
rv_pow2 : |
|
rv_pow5 : |
}
type real_literal_kind =
| |
RLitUnk |
| |
RLitDec of |
| |
RLitHex of |
type real_constant = {
|
rl_kind : |
|
rl_real : |
}
val neg_int : int_constant -> int_constant
val abs_int : int_constant -> int_constant
val neg_real : real_constant -> real_constant
val abs_real : real_constant -> real_constant
val compare_real : ?structural:bool -> real_value -> real_value -> intCompare two real values. By default, the comparison is structural, that is, two ordered values might compare differently.
val int_literal : int_literal_kind -> neg:bool -> string -> int_constant
val real_literal : radix:int ->
neg:bool ->
int:string -> frac:string -> exp:string option -> real_constantreal_literal ~radix ~neg ~int ~frac ~exp builds the real value
given by the mantissa int.frac and exponent exp. The radix
must be either 10 or 16. If radix is 16, then int and frac are
interpreted in hexadecimal (but not exp which is always in
decimal) and the base of the exponent is 2 instead of 10. The
resulting number is negative when neg is true.
Examples:
real_literal ~radix:10 ~neg:false ~int:"12" ~frac:"34" ~exp:(Some "-5")
denotes the number 12.34e-5,real_literal ~radix:10 ~neg:true ~int:"67" ~frac:"" ~exp:None
denotes -67,real_literal ~radix:16 ~neg:false ~int:"9A" ~frac:"B" ~exp:(Some "5")
denotes 0x9A.Bp5, i.e., 4950.val real_value : ?pow2:BigInt.t -> ?pow5:BigInt.t -> BigInt.t -> real_valuereal_value ~pow2 ~pow5 n builds the value n * 2 ^ pow2 * 5 ^ pow5.
typedefault_format =Stdlib.Format.formatter -> string -> unit
typeinteger_format =Stdlib.Format.formatter -> BigInt.t -> unit
typereal_format =Stdlib.Format.formatter -> string -> string -> string option -> unit
typefrac_real_format =(Stdlib.Format.formatter -> string -> unit) *
(Stdlib.Format.formatter -> string -> string -> unit)
typedelayed_format =Stdlib.Format.formatter -> (Stdlib.Format.formatter -> unit) -> unit
type number_support = {
|
long_int_support : |
|
negative_int_support : |
|
dec_int_support : |
|
hex_int_support : |
|
oct_int_support : |
|
bin_int_support : |
|
negative_real_support : |
|
dec_real_support : |
|
hex_real_support : |
|
frac_real_support : |
}
val full_support : number_support
val print_int_constant : number_support ->
Stdlib.Format.formatter -> int_constant -> unit
val print_real_constant : number_support ->
Stdlib.Format.formatter -> real_constant -> unit
val print_in_base : int -> int option -> Stdlib.Format.formatter -> BigInt.t -> unitprint_in_base radix digits fmt i prints the value of non-negative i
in base radix. If digits is not None, it adds leading 0s to have digits
characters.
val to_small_integer : int_constant -> int
type int_range = {
|
ir_lower : |
|
ir_upper : |
}
val create_range : BigInt.t -> BigInt.t -> int_range
exception OutOfRange of int_constant
val check_range : int_constant -> int_range -> unitcheck_range c ir checks that c is in the range described by ir.
OutOfRange if out of range.val int_range_equal : int_range -> int_range -> booltype float_format = {
|
fp_exponent_digits : |
|
fp_significand_digits : |
}
exception NonRepresentableFloat of real_constant
val compute_float : real_constant -> float_format -> bool * BigInt.t * BigInt.tcompute_float c fp checks that c is a float literal
representable in the format fp.
NonRepresentableFloat if not representable.s,e,m with s the sign (true if negative, false if positive),
e the biased exponentm, and the significand (without the hidden bit).val check_float : real_constant -> float_format -> unitcheck_float c fp is the same as compute_float c fp
but does not return any value.
val float_format_equal : float_format -> float_format -> bool