[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gambas-bugtracker] Bug #2921: Postgresql 19.900000000000055 is 20 in Gambas


http://gambaswiki.org/bugtracker/edit?object=BUG.2921&from=L21haW4-

Comment #7 by zxMarce:

Christof,

Well... it's not that floating point number representation is buggy in itself.
It is just a representation that, regardless of the value at hand (light-years or microscopic), it does the job in a preset, finite number of bytes.

Again, it is just one of several possible representations of a magnitude or value.

FLOATING-POINT:
Imagine a ladder; every step is a perfectly represented numeric value.
The problem comes when the height you want to go to is halfway between two steps.
But, the ladder has almost infinite height (although the steps are farther away the higher you go)!
There are three parts to such numbers: A sign bit, a mantissa, and an exponent.
If the mantissa multiplied by the (assumed) base elevated to the power of the exponent doe not equal the exact value to represent, you have the infamous "rounding error".

FIXED-POINT:
Imagine a rope; you can climb to the precise height you want. It is practically analog (key word here is "practically").
The problem comes when the rope does not reach the max height you may need to go (you ran out of bits in this case)!

To each one its own; you can use either float or fixed (or a combination!) depending on the type of application.
But when you need financial/scientific finesse, it is fixed-point all the way.

Oh, and I confirm that Gambas seems immune to my 4.85 "gotcha-trap" (darn, will have to look for a value that trips it). Well, I use 4.85 in the "other OS", so...

Regards,
--
zxMarce.


----[ Gambas bugtracker-list is hosted by https://www.hostsharing.net ]----