On 2016-11-30 3:14 PM, Keith Medcalf wrote:
On Wednesday, 30 November, 2016 17:58, Darren Duncan <dar...@darrenduncan.net>
said:
On 2016-11-30 2:43 PM, Keith Medcalf wrote:
You were given a good recommendation save everything in "cents". Which
might also be a good solution depending on the underlying language you
use. as you can't store money in a float!
And why can you not store money in a float?
Unlike say measured data like temperature or rainfall, which are
inherently
inexact, money is not measured and is considered exact information, at
least in
typical cases of recording transactions, so needs to be represented in an
exact
format. You don't want your bank balance to be changing by different
values
than the exact amount you insert or withdraw, do you? -- Darren Duncan
I do not follow.
There is no reason that money cannot be stored as IEEE754 floating point
(32-bit format lesser formats such as fast-float are more problematic than
64-bit or longer binary, but can easily handle more than 10 times all the money
every created), and it can certainly be stored in IEEE854 floating point.
Why exactly do you think there is a problem? Or is it really just a generally
observed wattage problem (in the understanding of numbers and arithmetic and
how computers work).
The problem is that IEEE floats are inexact. Even with 64-bit versions, summing
a lot of money values is eventually going to create rounding errors when
conceptually summing should always produce exact results, which we care about
when dealing with money. -- Darren Duncan
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users