Lurker News
Manipulating 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

Show all comments

Showing thread 32 of 50

atemerev2 replies#
Cool! As underlying values, do you use integers, bigdecimals, or a decimalized double hack like in OpenHFT?
eriksencosta1 reply#
It uses BigDecimal. My first goal with the library was to provide a well-designed API. So to keep it simple for myself, I relied on BigDecimal for the calculations.
atemerev#
I think you are right, API is the most important part; internal implementation can be optimized later.
vamega2 replies#
What is the double hack used in OpenHFT? I tried looking this up and came up short.
pcl#
I’ll byte. Perhaps you didn’t look long enough. I’m sure the answer will float by at some point.