On 2 Dec 2016, at 2:30am, James K. Lowden <jklow...@schemamania.org> wrote:

## Advertising

> Jens Alfke <j...@mooseyard.com> wrote:
>
>> I understand that the consensus among those who do is to _not_ store
>> monetary values as floating-point, due to the roundoff error.
>
> I wouldn't be so sure. I've worked in that space for 30 years designing
> databases and applications. I don't remember once representing money as
> anything but floating point, except on mainframes. Occasionally we
> used exact-decimal database types for bulk-load tables, to verify the
> vendor's promised 18,6 scaling factor. But in production? For
> computation? Floats, always and ever.
Floating point is fine for science. And for calculations in banking which
inherently deal with non-integers (e.g. compound interest). But once you’ve
finished your compound interest calculation you are going to round the result
in exactly the way you were told to, and you will store it as an amount of
money which you can exactly hand over to the account-holder in cash.
To do anything else would mean that any audit required endless tedious
calculations to prove you weren’t adding up fractions to sneak our an odd pound
or penny. Plus endless checking to see that no amount corresponding to a
transaction was a fractional unit of currency.
(The fact that some prices and exchange rates manipulate currencies as
"percentage in point", meaning that a dollar is 10000 "pips" not 100 "cents",
is considered unhelpful in the extreme to my point !)
Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users