relude icon indicating copy to clipboard operation
relude copied to clipboard

Decimal type

Open andywhite37 opened this issue 5 years ago • 2 comments

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.

andywhite37 avatar Apr 29 '19 21:04 andywhite37

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.

andywhite37 avatar May 06 '19 23:05 andywhite37

I started a Relude_Decimal type (backed by an int mantissa and an int exponent) as a placeholder, but it's not yet complete.

andywhite37 avatar May 13 '19 16:05 andywhite37