Arbitrary-size, safe floating point number
with the explicit option of allowing of exceptions or not.
See also Decimal.Morph
Any Decimal except 0 is represented this way
What comes after its Sign
Some digits after the decimal point. Can't be none.
Note that "fraction" here doesn't mean "rational number with a numerator and denominator" or "number in range [0;1]" It means: the absolute value of a written decimal number without a period, like 0.345 or 0.001
You think this name can be improved? → issue
Absolute value of a signed Decimal ≥ 1
Non-number calculation result, see also IEEE 754 number exception states
Result Exception Decimal for example is like an elm/core Float
except
Convert from an elm/core Float.
Don't be surprised to find more precise representations in Decimal-land
-9999.124 |> Decimal.fromFloat
--→ Ok with the Decimal representation of
--→ 999.1239999999997962731868028640747070312Convert to a Float
Keep in mind that DecimalOrException -> Float can be lossy
since Float is fixed in bit size while Decimal is not
NaN, infinity or Decimal.toFloat
Keep in mind that Decimal -> Float can be lossy
since Float is fixed in bit size while Decimal is not
infinity/NaN represented as a Float
Print an Exception
The type is rarely useful in its current state, as the only thing you can do is convert from and to other types.
This is enough for my use-cases but feel free to PR or open an issue if you'd like to see support for arbitrary-precision arithmetic like addition, multiplication, ...
A decimal number that can have a floating point
Don't shy away from spinning your own version of this if needed, like
See also
Decimal.Exception