3 ms·
I'm building a language tailored for business app and for long time I was thinking in make decimals the first-class treatment. ie, when doing "total = 1.3 + 2
by mamcx 8y ago
I'm building a language tailored for business app and for long time I was thinking in make decimals the first-class treatment.
ie, when doing "total = 1.3 + 2 * 10%" all this is in decimal. To make float "total = 1.3f + 2f * 10%".
The reason is that most, if not all, the calculations in my life are around money. I only use floats because that is what every language make me do.
However, I wish to know how do this robustly. How not rely on hacks? How do this ok? I'm working in rust for this.
- simonbyrne 8y agoYour best bet might be wrapping the Intel decimal floating point library: https://software.intel.com/en-us/articles/intel-decimal-floating-point-math-library https://software.intel.com/en-us/articles/intel-decimal-floa... This is a software implementation of the standardized IEEE decimal format.
- mamcx 8y agoIs that better than http://speleotrove.com/decimal/decnumber.html http://speleotrove.com/decimal/decnumber.html? But, apart to just have a decimal datatype + overload the operators and provide some functions, exist something else I need to be aware?
- simonbyrne 8y agoI'm not really sure, but from a quick skim it seems that the Intel library provides standard math functions (log, exp, sin, etc.), whereas the speleotrove library does not. Also the speleotrove one doesn't appear to have been updated since 2010.