finos/morphir-elm/8.0.0

NOTE: the latest version is 22.0.2

Formerly Morgan-Stanley/morphir-elm. Search finds this package by either name.

Morphir.SDK.Decimal

The datatype

type alias Decimal =
Decimal

The Decimal data type

Convert from

fromInt : Int -> Decimal

Converts an Int to a Decimal

fromFloat : Float -> Maybe Decimal

Converts a Float to a Decimal

fromString : String -> Maybe Decimal

Converts a String to a Maybe Decimal. The string shall be in the format [<sign>]<numbers>[.<numbers>][e<numbers>]

Convert from known exponent

hundred : Int -> Decimal

Converts an Int to a Decimal that represents n hundreds.

thousand : Int -> Decimal

Converts an Int to a Decimal that represents n thousands

million : Int -> Decimal

Converts an Int to a Decimal that represents n millions.

tenth : Int -> Decimal

Converts an Int to a Decimal that represents n tenths.

hundredth : Int -> Decimal

Converts an Int to a Decimal that represents n hundredths.

millionth : Int -> Decimal

Converts an Int to a Decimal that represents n millionth.

bps : Int -> Decimal

Converts an Int to a Decimal that represents n basis points (i.e. 1/10 of % or a ten-thousandth

Convert to

toString : Decimal -> String

Converts a Decimal to a String

toFloat : Decimal -> Float

Converts a Decimal to a Float

Arithmetic operations

add : Decimal -> Decimal -> Decimal

Addition

sub : Decimal -> Decimal -> Decimal

Subtraction

negate : Decimal -> Decimal

Changes the sign of a Decimal

mul : Decimal -> Decimal -> Decimal

Multiplication

Rounding

truncate : Int -> Decimal -> Decimal

Truncates the Decimal to the specified decimal places

round : Int -> Decimal -> Decimal

Rounds the Decimal to the specified decimal places

Comparing

gt : Decimal -> Decimal -> Bool

Greater than

gte : Decimal -> Decimal -> Bool

Greater than or equals

eq : Decimal -> Decimal -> Bool

Equals

neq : Decimal -> Decimal -> Bool

Not equals

lt : Decimal -> Decimal -> Bool

Less than

lte : Decimal -> Decimal -> Bool

Less than or equals

compare : Decimal -> Decimal -> Order

Compares two Decimals

Misc operations

abs : Decimal -> Decimal

Absolute value (sets the sign as positive)

Common Constants

zero : Decimal

The number 0

one : Decimal

The number 1

minusOne : Decimal

The number -1