relude
relude copied to clipboard
Decimal type
It would be handy to have a arbitrary precision numeric type, like BigDecimal from Java/Scala.
We could also consider adding a Numeric
typeclass that could be brought into scope for a specific numeric type to give access to basic infix operators.
I found this pretty simple & straightforward implementation that we could use for inspiration: https://github.com/bagilevi/bs-decimal
It's backed by an int
value and an int
scale, so there would be some limitations around max side of values, but I think it would work fine for most purposes - e.g. representing "reasonable" monetary values in apps, etc.
I started a Relude_Decimal
type (backed by an int mantissa and an int exponent) as a placeholder, but it's not yet complete.