package containers

  1. Overview
  2. Docs
On This Page
  1. Infix Operators
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module CCFloatSource

Basic operations on floating-point numbers

  • since 0.6.1
Sourcetype t = float
Sourcetype fpclass = fpclass =
  1. | FP_normal
  2. | FP_subnormal
  3. | FP_zero
  4. | FP_infinite
  5. | FP_nan
Sourceval nan : t

nan is Not a Number (NaN). Equal to Stdlib.nan.

Sourceval max_value : t

max_value is Positive infinity. Equal to Stdlib.infinity.

Sourceval min_value : t

min_value is Negative infinity. Equal to Stdlib.neg_infinity.

Sourceval max_finite_value : t

max_finite_value is the largest finite float value. Equal to Stdlib.max_float.

Sourceval epsilon : t

epsilon is the smallest positive float x such that 1.0 +. x <> 1.0. Equal to Stdlib.epsilon_float.

Sourceval pi : t

pi is the constant pi. The ratio of a circumference to its diameter.

  • since 3.0
Sourceval is_nan : t -> bool

is_nan f returns true if f is NaN, false otherwise.

Sourceval add : t -> t -> t

add x y is equal to x +. y.

Sourceval sub : t -> t -> t

sub x y is equal to x -. y.

Sourceval neg : t -> t

neg x is equal to ~-. x.

Sourceval abs : t -> t

abs x is the absolute value of the floating-point number x. Equal to Stdlib.abs_float.

Sourceval scale : t -> t -> t

scale x y is equal to x *. y.

Sourceval min : t -> t -> t

min x y returns the min of the two given values x and y.

Sourceval max : t -> t -> t

max x y returns the max of the two given values x and y.

Sourceval equal : t -> t -> bool

equal x y is true if x and y are the same.

Sourceval compare : t -> t -> int

compare x y is Stdlib.comparexy.

Sourcetype 'a printer = Format.formatter -> 'a -> unit
Sourcetype 'a random_gen = Random.State.t -> 'a
Sourceval pp : t printer
Sourceval hash : t -> int
Sourceval random : t -> t random_gen
Sourceval random_small : t random_gen
Sourceval random_range : t -> t -> t random_gen
Sourceval fsign : t -> t

fsign x is one of -1., -0., +0., +1., or nan if x is NaN.

  • since 0.7
Sourceval round : t -> t

round x returns the closest integer value, either above or below. For n + 0.5, round returns n.

  • since 0.20
Sourceexception TrapNaN of string
Sourceval sign_exn : t -> int

sign_exn x will return the sign of x as 1, 0 or -1, or raise an exception TrapNaN if x is NaN. Note that infinities have defined signs in OCaml.

  • since 0.7
Sourceval to_int : t -> int

Alias to int_of_float. Unspecified if outside of the range of integers.

Sourceval of_int : int -> t

Alias to float_of_int.

Sourceval to_string : t -> string
Sourceval of_string_exn : string -> t

Alias to float_of_string.

  • since 1.2
Sourceval of_string_opt : string -> t option
  • since 3.0
Sourceval equal_precision : epsilon:t -> t -> t -> bool

Equality with allowed error up to a non negative epsilon value.

Sourceval classify : t -> fpclass

classify x returns the class of the given floating-point number x: normal, subnormal, zero, infinite or nan (not a number).

Infix Operators

  • since 0.17
Sourcemodule Infix : sig ... end
include module type of Infix
Sourceval (=) : t -> t -> bool
  • since 0.17
Sourceval (<>) : t -> t -> bool
  • since 0.17
Sourceval (<) : t -> t -> bool
  • since 0.17
Sourceval (>) : t -> t -> bool
  • since 0.17
Sourceval (<=) : t -> t -> bool
  • since 0.17
Sourceval (>=) : t -> t -> bool
  • since 0.17
Sourceval (+) : t -> t -> t

Addition.

  • since 2.1
Sourceval (-) : t -> t -> t

Subtraction.

  • since 2.1
Sourceval (~-) : t -> t

Unary negation.

  • since 2.1
Sourceval (*) : t -> t -> t

Multiplication.

  • since 2.1
Sourceval (/) : t -> t -> t

Division.

  • since 2.1
OCaml

Innovation. Community. Security.