|
|
|
|
|
by wyldfire
1482 days ago
|
|
> binary coded decimal floating point routines and financial functions for calculating the time value of money, depreciation, etc Wow what was the utility of BCD for these applications? My only experience with BCD is with RTCs. I always assumed that the RTCs had been designed for driving a simple display like 7-segment lcd. But doing floating point in BCD? I guess the 8087 wasn't common yet but maybe soft float using twos complement wasn't common either? |
|
You need basic addition and subtraction to always be exact (e.g. $15.27 + $91.31 needs to come out as $106.58, not $106.5799999999999999999998), and for operations that may have remainders beyond your desired number of digit precision, you need deterministic rounding or other rules to handle it.
If you're ever writing any code that handles money, DO NOT use just naively use float and double types in your code!