Module Utils.Arith_utils

Utility functions for floating point arithmetic

val is_int : float -> bool

Checks if a float is an integer

Note that -0 is not considered an integer

val is_normal : float -> bool

Checks if a flot is not NaN or infinite

val to_int : float -> float

Rounds a float towards 0

Returns 0 if NaN, and unchanged if infinite

val to_int32 : float -> float

Same as to_int, but overflows as if it's a signed 32-bit int

val to_uint32 : float -> float

Same as to_int32, but for unsigned 32-bit ints

val to_uint16 : float -> float

Same as to_uint32, but for unsigned 16-bit ints

val int64_bitwise_not : Z.t -> Z.t
val int64_bitwise_and : Z.t -> Z.t -> Z.t
val int64_bitwise_or : Z.t -> Z.t -> Z.t
val int64_bitwise_xor : Z.t -> Z.t -> Z.t
val int64_left_shift : Z.t -> Z.t -> Z.t
val int64_right_shift : float -> float -> float
val uint64_right_shift : float -> float -> float
val int32_bitwise_not : float -> float
val int32_bitwise_and : float -> float -> float
val int32_bitwise_or : float -> float -> float
val int32_bitwise_xor : float -> float -> float
val int32_left_shift : float -> float -> float
val int32_right_shift : float -> float -> float
val uint32_right_shift : Z.t -> Z.t -> Z.t
val uint32_right_shift_f : float -> float -> float
val uint64_int_right_shift : Z.t -> Z.t -> Z.t
val string_of_pos_float : float -> string

Stringifies a float, adapting based on its size, or whether it's an integer

Assumes the float is normal and positive

val float_to_string_inner : float -> string

Stringifies a float, considering negative and abnormal cases