finos / morphir-elm / Morphir.SDK.Decimal

The datatype


type alias Decimal =
Decimal

The Decimal data type

Convert from

fromInt : Basics.Int -> Decimal

Converts an Int to a Decimal

fromFloat : Basics.Float -> 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 [][.][e]

Convert from known exponent

hundred : Basics.Int -> Decimal

Converts an Int to a Decimal that represents n hundreds.

thousand : Basics.Int -> Decimal

Converts an Int to a Decimal that represents n thousands

million : Basics.Int -> Decimal

Converts an Int to a Decimal that represents n millions.

tenth : Basics.Int -> Decimal

Converts an Int to a Decimal that represents n tenths.

hundredth : Basics.Int -> Decimal

Converts an Int to a Decimal that represents n hundredths.

thousandth : Basics.Int -> Decimal

Converts an Int to a Decimal that represents n thousandths.

millionth : Basics.Int -> Decimal

Converts an Int to a Decimal that represents n millionth.

bps : Basics.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

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

div : Decimal -> Decimal -> Maybe Decimal

Divide two decimals

divWithDefault : Decimal -> Decimal -> Decimal -> Decimal

Divide two decimals providing a default for the cases the calculation fails, such as divide by zero or overflow/underflow.

Rounding

truncate : Decimal -> Decimal

Truncates the Decimal to the nearest integer with TowardsZero mode

round : Decimal -> Decimal

round to the nearest integer.

Comparing

gt : Decimal -> Decimal -> Basics.Bool

Greater than

gte : Decimal -> Decimal -> Basics.Bool

Greater than or equals

eq : Decimal -> Decimal -> Basics.Bool

Equals

neq : Decimal -> Decimal -> Basics.Bool

Not equals

lt : Decimal -> Decimal -> Basics.Bool

Less than

lte : Decimal -> Decimal -> Basics.Bool

Less than or equals

compare : Decimal -> Decimal -> Basics.Order

Compares two Decimals

Misc operations

abs : Decimal -> Decimal

Absolute value (sets the sign as positive)

shiftDecimalLeft : Basics.Int -> Decimal -> Decimal

Shift the decimal n digits to the left.

shiftDecimalRight : Basics.Int -> Decimal -> Decimal

Shift the decimal n digits to the right.

Common Constants

zero : Decimal

The number 0

one : Decimal

The number 1

minusOne : Decimal

The number -1