Earlier quoted context omitted.
why add the complexity of bcd when you can just put in it units (e.g. cents) where there's no decimal point?
What do you do if heavy deflation causes the government to release a $0.001 coin? A cent isn't a fundamental unit. Edit: as another hypothetical, what if the $0.001 coin is released to support micropayment use cases?
64-bit bank balances ‘ought to be enough for anybody’?
81–90 of 372 posts
Re: 64-bit bank balances ‘ought to be enough for anybody’?
#82Earlier quoted context omitted.
I had such case too, the solution is simple: round in favor of the bank / financial institution you are working for
No, it does not work this way. Any good accountant will see a different in values, even smallest one, as a sign of an incorrect calculation. Does not matter which way it goes, they will feel compelled to figure out who is wrong. At least a good accountant will.
Re: 64-bit bank balances ‘ought to be enough for anybody’?
#83I was under the impression that BCD was generally recommended for money, often because of (IEEE?) rounding and machine precision/epsilon: * https://en.wikipedia.org/wiki/Binary-coded_decimal * https://en.wikipedia.org/wiki/Machine_epsilon
BCD is better than IEEE 754 floating point, but simple integers with an implied decimal point is much better than either of those.
So it's useful for applications where you're mostly doing human input/output stored value.
But as soon as you do any non-trivial math on those values, using (fixed point?) integers wins. At the cost of a simple stored value human readable conversion.
I'd think most financial applications fall into the category "do math, so integers win over BCD".
Re: 64-bit bank balances ‘ought to be enough for anybody’?
#84Earlier quoted context omitted.
What do you do if heavy deflation causes the government to release a $0.001 coin? A cent isn't a fundamental unit. Edit: as another hypothetical, what if the $0.001 coin is released to support micropayment use cases?
These systems use something like 10^-8 as the implied decimal in the real world. Some forex exchanges even go to 10^-9
Re: 64-bit bank balances ‘ought to be enough for anybody’?
#85Earlier quoted context omitted.
Floating point being grokkable doesn’t make it any more suitable for this application. Floating point is inherently an approximation - your bank balance should not be an approximation.
> Floating point is inherently an approximation - your bank balance should not be an approximation. I think this is a perfect example of bad floating point teaching. Floating point is not an approximation in any sense. If the numerical result of your calculation is representable in floating point you will get an exact answer always. And for results that aren't representable you decide exactly what should be done abou…
Re: 64-bit bank balances ‘ought to be enough for anybody’?
#86Earlier quoted context omitted.
For very simple billing, arbitary precision sounds like overkill, as do rounding, and order of operations.
Oh, sure, because when you are a small company you don't care that people get correct invoices. I can certainly sympathise with this stance. There is about a billion things you can do better but you have limited time to do anything so you have to prioritise. And if one invoice in ten thousand is incorrect by one cent, and only one client in ten thousand who received the wrong invoice will actually find it out, then i…
Re: 64-bit bank balances ‘ought to be enough for anybody’?
#87Earlier quoted context omitted.
I have a personal anecdote on this subject. A long time ago I worked at a bank and I had to calculate a large number of accounts regarding agricultural loans. These were state sponsored loans. When I finished my task (this was a Java job), I found that sometimes the results were off by $0.01. So I asked my boss how I should do the rounding, to which he replied that an error of up to $1 was acceptable. If I recall cor…
On my first day in a new company, not even senior dev yet, I met with the head accountant. I asked about her top problems, she said her top problem was that the application would produce different invoice on screen, different invoice when printed as PDF and a different invoice in the accounting software. About 1% of all invoices were affected but due to amount of billing they were doing (telecommunications and advert…
Your setup made it sound like something crazy and inane, like "the PDF printer used on those machines changed floating point rounding modes" or what have you.
Re: 64-bit bank balances ‘ought to be enough for anybody’?
#88Earlier quoted context omitted.
Floating point being grokkable doesn’t make it any more suitable for this application. Floating point is inherently an approximation - your bank balance should not be an approximation.
> Floating point is inherently an approximation - your bank balance should not be an approximation. I think this is a perfect example of bad floating point teaching. Floating point is not an approximation in any sense. If the numerical result of your calculation is representable in floating point you will get an exact answer always. And for results that aren't representable you decide exactly what should be done abou…
A `float` on the other hand, approximates the real numbers. It can perfectly represent exactly 0% of them.
Having control over the rounding behavior is meaningless - floats cannot correctly represent any non-contrived calculation. Exact representation is important in financial systems.
Re: 64-bit bank balances ‘ought to be enough for anybody’?
#89Earlier quoted context omitted.
What do you do if heavy deflation causes the government to release a $0.001 coin? A cent isn't a fundamental unit. Edit: as another hypothetical, what if the $0.001 coin is released to support micropayment use cases?
Actually that would break so many things (the cent as the smallest unit in law and in custom where that is currently the case) that governments may by preference issue a whole new currency instead of stir that pot.
> https://www.law.cornell.edu/uscode/text/31/5101 says "United States money is expressed in dollars, dimes or tenths, cents or hundreths,[1] and mills or thousandths. A dime is a tenth of a dollar, a cent is a hundredth of a dollar, and a mill is a thousandth of a dollar."
> [1] So in original. Probably should be “hundredths,”.
About the only time you see values given in mills is with gas prices, like $4.999/gal, though often denoted as tenths of a cent. It's also indirectly used in property taxes.
Re: 64-bit bank balances ‘ought to be enough for anybody’?
#90Earlier quoted context omitted.
Wouldn't we just re-base the currency at that point?
That “just” is doing some very heavy lifting. That could potentially involve having to update almost every financial system worldwide given the US dollar’s position as a global reserve currency.
If hyperinflation brings that date closer, the dollar will probably also stop being a global reserve. Or possibly: will be caused by it ceasing to be a global reserve.