← all modules

Std.Decimal

Std.Decimal
  Std.Decimal — arbitrary-precision decimal arithmetic (Layer 3 Sky source).

Types
  type Decimal

Values
  abs : Decimal -> Decimal
  add : Decimal -> Decimal -> Decimal
  addPercent : Decimal -> Decimal -> Decimal
  ceil : Decimal -> Decimal
  compare : Decimal -> Decimal -> Int
  div : Decimal -> Decimal -> Result Error Decimal
  eq : Decimal -> Decimal -> Bool
      Equal values (`eq 1.10 1.1` is True). Since v0.29.2 Sky `==` on two
  floor : Decimal -> Decimal
  formatWith : String -> String -> Int -> Decimal -> String
      `formatWith thousandsSep decimalSep places d`
  fromFloat : Float -> Decimal
      The decimal of a Float, its shortest exact text (`0.1` is `0.1`). A NaN or
  fromInt : Int -> Decimal
  fromMinor : Int -> Int -> Decimal
      `fromMinor 2 12345` → 123.45  (cents → dollars).
  fromString : String -> Result Error Decimal
      Read a decimal from text: `"12.34"`, `"-0.5"`, or with an exponent,
  gt : Decimal -> Decimal -> Bool
  gte : Decimal -> Decimal -> Bool
  isNegative : Decimal -> Bool
  isPositive : Decimal -> Bool
  isZero : Decimal -> Bool
  lt : Decimal -> Decimal -> Bool
  lte : Decimal -> Decimal -> Bool
  max : Decimal -> Decimal -> Decimal
  min : Decimal -> Decimal -> Decimal
  mod : Decimal -> Decimal -> Result Error Decimal
  mul : Decimal -> Decimal -> Decimal
  neg : Decimal -> Decimal
  neq : Decimal -> Decimal -> Bool
  one : Decimal
  oneHundred : Decimal
  percentOf : Decimal -> Decimal -> Decimal
  round : Int -> Decimal -> Decimal
      Banker's rounding (round-half-to-even).
  roundHalfUp : Int -> Decimal -> Decimal
  sub : Decimal -> Decimal -> Decimal
  subPercent : Decimal -> Decimal -> Decimal
  sum : List Decimal -> Decimal
      Sum a list of Decimals.
  toFloat : Decimal -> Float
      The Float nearest the decimal, for display (lossy). A decimal past the
  toInt : Decimal -> Int
      The whole part (`toInt 3.9` is 3, `toInt -3.9` is -3). A whole part
  toMinor : Int -> Decimal -> Int
      `toMinor 2 3.14` is 314, the inverse of `fromMinor`; the fraction past
  toString : Decimal -> String
  toStringFixed : Int -> Decimal -> String
  truncate : Int -> Decimal -> Decimal
  zero : Decimal