Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Steve's Programming Challenge: Weights and Measures
#7
(08-16-2024, 12:24 AM)dano Wrote: I wrote my program to check all combinations of the above and discovered that the .1 LB could get close, but not exact:

Exactly. And that's the error which we see in floating point math. We can get close to representing some values, but never exact. Wink

That *close but not exact* is the cause of floating point errors that we see when doing math. It's simply impossible to perfectly represent some values in binary-numbers, just as it's impossible to perfectly represent some numbers in standard base-10 values.

What is 1/3 as a decimal?

0.33333333333333333333333333333333333333333333333333333333333(keep holding down that 3 key... you haven't got it perfect yet...)

We can't perfectly represent 1/3 in decimal.

We also can't perfectly represent 1/10 in binary. We get "close, but not exact", and that "close" is where our math errors and rounding errors occur over time in our programs.
Reply


Messages In This Thread
RE: Steve's Programming Challenge: Weights and Measures - by SMcNeill - 08-16-2024, 12:35 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Steve is on vacation SMcNeill 9 966 11-06-2025, 06:55 PM
Last Post: TempodiBasic
  personal coding challenge results James D Jarvis 4 626 06-20-2025, 03:20 PM
Last Post: James D Jarvis
  QB64PE programming challenge? auto-convert image to photoreal etch-a-sketch drawing madscijr 9 1,864 02-14-2025, 05:49 PM
Last Post: madscijr
  For what it’s worth: Programming Clarity PhilOfPerth 11 2,257 07-27-2024, 03:15 PM
Last Post: bplus
  Vintage programming BigPete 4 894 05-15-2024, 09:57 AM
Last Post: BigPete

Forum Jump:


Users browsing this thread: 1 Guest(s)