Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Possible floating point error?
#3
(@Jack beat me to it and said it more concisely.)

Steve has mentioned in previous posts how some numbers cannot be represented exactly in binary floating point, and that seems to be the case here.

That tiny error is not a bug, it's just because of the difference between our expectations and the way floats are represented internally.

That's why financial institutions prefer decimal math to binary.  If every $100 transfer is recorded as $99.99999, then those bank execs are going to have headaches.

In everyday use little errors like that can either cancel out over time or add up to something more noticeable.

(I seem to recall that in olden time some MS Basics would ever so slightly round floats before printing them to hide those ugly inaccuracies.)


Interesting.
f = 2 / 454
x = 227 * f
yields .9999999

while
x = (2 / 454) * 227
yields 1.
Reply


Messages In This Thread
Possible floating point error? - by TerryRitchie - 05-30-2024, 01:02 AM
RE: Possible floating point error? - by Jack - 05-30-2024, 01:34 AM
RE: Possible floating point error? - by JRace - 05-30-2024, 01:48 AM
RE: Possible floating point error? - by SMcNeill - 05-30-2024, 02:30 AM
RE: Possible floating point error? - by SMcNeill - 05-30-2024, 03:31 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Mac debugger not connecting, a user error! BlameTroi 0 110 02-07-2026, 06:18 PM
Last Post: BlameTroi
  ERROR MESSAGES COLORS ? aurel 5 399 01-02-2026, 11:26 AM
Last Post: aurel
  Using CONST & _RGB used together seem to error... Dav 12 714 12-12-2025, 12:29 AM
Last Post: Dav
  error doing image collision detection with _MemGet madscijr 55 4,769 10-01-2025, 03:25 PM
Last Post: bplus
  error on function returning _mem Herve 5 698 07-05-2025, 08:06 PM
Last Post: hsiangch_ong

Forum Jump:


Users browsing this thread: 1 Guest(s)