Show HN: Kotlin Money (opens in a new tab)blog.eriksen.com.br
427 pointsManipulating monetary amounts is a common computing chore. However, no mainstream language has a first-class data type for representing money, it’s up to programmers to code abstractions for it. This isn’t an issue per se until dealing with rounding issues from operations like installment payments (e.g., buy now, pay later), foreign exchange, or even simple things like fee processing and tax collection.
Inspired by my days at N26 Brasil dealing with these challenges, I introduce Money: a Kotlin library that makes monetary calculations and allocations easy.

Comments (228) 50 threads
Earlier commentsThis one seems to carry units, as in, it is not a type with math for a known amount of fixed point precision that differentiates this library, but that it captures that plus the unit -- the currency, USD, EUR, etc -- that it is in.
This comes into play if you have to do aggregate functions across tens of thousands of rows and can kill performance compared to integers.
Your presentation layer is probably always going to need to do some manipulation of the number anyway (put a dollar sign on it, etc) so using a decimal amount just for presentation needs isn't a huge win. But it will work too.
(see roundN)
Be careful and use it only if you know what you are doing and understand the limitations.
All comments shown.
Couldn't load more comments. Check your connection and try again.