Open seandenigris opened 3 years ago
Hi @seandenigris , Aconcagua uses the numeric infrastructure the language provided. For modelling monetary units is usually not a good idea to use floats due to its inexact behavior, unless you're doing some approximation that has no analytical counterpart in which case there's already an error margin considered.
So, in the common case you can use fractions if you need absolute precision or a fixed point kind number for the internal representation. Of course you will need some "formatters" to get a user friendly representation of the number especially when using fractions as the underlying representation. And you will need probably some way to round the monetary measurements to his minimal representation when representing things like payments that are not allowed to have an arbitrary number of decimal places.
I'd like to add some information to the docs about modeling money. This has come up many times on the MLs of the various Smalltalk flavors, and Aconcagua has been mentioned many times. However, even after reading and re-reading, I'm still not clear how Aconcagua addresses the float problem. Namely, by way of example:
At first, I thought that using
ScaledDecimal
might help, but there were various comments saying that Pharo's ScaledDecimal is ill-conceived and maybeFixedDecimal
would be better.Another solution I thought of would be to convert any decimal money to dollars and cents and only convert back for display. For example:
Any feedback or input would be appreciated...
@gcotelli @mtaborda @hernanwilkinson