themis/number

Types

pub type ComparisonError {
  NaNValue
}

Constructors

  • NaNValue

Prometheus numbers. Helpful for displaying and adding/comparing values of different types.

pub type Number {
  PosInf
  NegInf
  NaN
  Dec(Float)
  Int(Int)
}

Constructors

  • PosInf
  • NegInf
  • NaN
  • Dec(Float)
  • Int(Int)

Functions

pub fn add(value1 val1: Number, value2 val2: Number) -> Number

Add two numbers. Any NaN input value will always return NaN. PosInf + NegInf = NaN

pub fn compare(
  compare val1: Number,
  to val2: Number,
) -> Result(Order, ComparisonError)

Compare two numbers (see gleam_stdlib/order) Will return an error if either value is NaN

pub fn decimal(value value: Float) -> Number

Creates a Number representing a decimal value.

pub fn integer(value value: Int) -> Number

Creates a Number representing an integer value.

pub fn negative_infinity() -> Number

Creates a Number representing negative infinity.

pub fn not_a_number() -> Number

Creates a Number representing NaN (Not a Number).

pub fn positive_infinity() -> Number

Creates a Number representing positive infinity.

pub fn print(number: Number) -> String

Prometheus-scrapable representation of a number

Search Document