Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> However, no mainstream language has a first-class data type for representing money...

I beg to differ. Java has "Decimal" class which guarantees to be safe from IEEE754 floating number side effects, and specially created to handle cases like money and financial calculations.

In these days it's used as BigDecimal, it seems [1].

[0]: https://docs.oracle.com/javase/8/docs/api/java/text/DecimalF... [1]: https://docs.oracle.com/en/java/javase/23/docs/api/java.base...



Can BigDecimal tell me which currency a monetary value is denominated in?


No, but Java has a specification (JSR 354) to build money and currency APIs [0].

A library built upon it can be found here [1].

[0]: https://jcp.org/en/jsr/detail?id=354

[1]: https://javamoney.github.io/


Tell me you've never worked in fintech without telling me you've never worked in fintech :)

Decimals aren't enough. You have frequent currency conversions and all sorts of other chores. Using a fixed-decimal datatype doesn't solve those problems by itself, it's just a tactic.


See JSR-354 then: https://jcp.org/en/jsr/detail?id=354

Yes, I never worked in fintech, but lots of my family members work or worked in banking sector. So, I'm not an alien when it comes to money, and how it works and processed in IT side of the things.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: