Up

Module Extended_float

Extensions to Core.Float.

Signature

val pretty : ?on_negative:[
| `Blow_up
| `Normal
| `Print_dir
] -> float -> string

pretty-print a float using no more than five characters, using abberviations k, m, g, t.

if on_negative is not set to `Normal then the resulting is never over four chars but upon negative number we either:

  • raise a failure
  • or print "<0"
val to_string_hum : float -> string
val order_of_magnitude_difference : float -> float -> int

order_of_magnitude_difference a b by how many orders of magnitude do a and b differ? The return value is non-negative.

examples:

  • order_of_magnitude_difference 11. 1001. = 2
  • order_of_magnitude_difference 1001. 11. = 2
  • order_of_magnitude_difference 131. 11. = 1
  • order_of_magnitude_difference 200. 0.003 = 5
include Number.Verified_std with type repr = Core.Std.Float.t
type repr = Core.Std.Float.t
module type S = Number.S with type repr = repr
Abbreviations
module type S0 = Number.S0 with type repr = repr
module Pos : S with type t = private repr
Positive and negative numbers with and without zero.
module Pos0 : S0 with type t = private repr
module Neg : S with type t = private repr
module Neg0 : S0 with type t = private repr
module type Bounded_spec = sig .. end
Specification of bounded numbers
module type Bounded = sig .. end
Signature of bounded numbers
module Make_bounded (Spec : Bounded_spec) : Bounded with type t = private repr
Functor of creating bounded numbers

Unsafe modules and functors that still fully expose the representation for extensibility.

module Pos_unsafe : S with type t = repr
module Pos0_unsafe : S0 with type t = repr
module Neg_unsafe : S with type t = repr
module Neg0_unsafe : S0 with type t = repr
module type Fraction = sig .. end
module Fraction : Fraction with type t = private Core.Std.Float.t