Re: [sqlite] Question about floating point

2018-12-16 Thread Wout Mertens
On Sat, Dec 15, 2018 at 7:13 PM Keith Medcalf wrote: > > >And yet ... here we are. The post which started this thread summed > >currency amounts and reached a total of 211496.252 . > > >Yes, you can say 'that would have been rounded before it was > >printed'. But then you're into the ol

Re: [sqlite] Question about floating point

2018-12-16 Thread Simon Slavin
On 16 Dec 2018, at 2:54pm, Wout Mertens wrote: > imagine having to handle the Zimbabwean Dollar, which ended up having 100 > trillion dollar notes. Good way to overflow your integers. Indeed. But when the crisis started in the early 2000s, the currency was devalued by 1000. Then ten zeros we

Re: [sqlite] Question about floating point

2018-12-16 Thread Keith Medcalf
Just remember however that you only have 53-bits of precision, so in floating point adding a "small" number (eg, 0.01) to a big number (1e16) the result will be 1e16 not 1.1e16 whereas with scaled decimal the result will be precise and that unless special precautions are taken t

Re: [sqlite] Question about floating point

2018-12-16 Thread Thomas Kurz
> Good way to overflow your integers. > With floating point, that's not a problem. With int64, it shouldn't be a problem either. ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/s

Re: [sqlite] Question about floating point

2018-12-16 Thread Wout Mertens
Ah, the luxuries of not programming in JavaScript ;) Anyway, using int64 would not have been sufficient to represent, say, tax numbers for the country, especially if you worked with cents. Whereas 53 bits of precision gets you a very long way and can even handle deflation The Wout. On Sun, D

Re: [sqlite] Question about floating point

2018-12-16 Thread Gary R. Schmidt
On 2018-12-17 02:41, Simon Slavin wrote: On 16 Dec 2018, at 2:54pm, Wout Mertens wrote: imagine having to handle the Zimbabwean Dollar, which ended up having 100 trillion dollar notes. Good way to overflow your integers. Indeed. But when the crisis started in the early 2000s, the currency w

Re: [sqlite] Question about floating point

2018-12-16 Thread Darren Duncan
On 2018-12-15 2:15 AM, Frank Millman wrote: On 2018-12-14 11:24 AM, Darren Duncan wrote: If yours is a financial application then you should be using exact numeric types only, such as integers that represent multiples of whatever quantum you are using, such as cents; fractional numbers are a di

Re: [sqlite] Question about floating point

2018-12-16 Thread D Burgess
> Banks still use, as they have for a very long time, Binary Coded > Decimal, or some equivalent that does not suffer from a loss of > accuracy, so all this foofaraw to do with floating point representation > of various amounts of currency does not apply to the real world. > > Cheers, >

Re: [sqlite] Question about floating point

2018-12-16 Thread Darren Duncan
On 2018-12-16 6:54 AM, Wout Mertens wrote: I'd also like to point out a problem with integer money: inflation. For USD it's been OK so far, but imagine having to handle the Zimbabwean Dollar, which ended up having 100 trillion dollar notes. Good way to overflow your integers. With floating point

Re: [sqlite] [EXTERNAL] Re: Question about floating point

2018-12-16 Thread Hick Gunter
That is why integer money amounts have a value/scale pair instead of mantissa/exponent. I don't expect you would be given change in the dimension of 1 "zimba" if you need 100 trillion to pay for a tank of gas. The principle behind money = v * 10 ^ -s is just the same as float = m * 2 ^e, but a