Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Coding - Comparison test gone wrong?
#3
I did print out up to the 15th decimal place. Also note how on the Before-After check, x was printed without any formatting, so perhaps the fprintf function did the truncating itself.

But anyway, I got it working with
while (x - limit > 10^(-15))
so I'm assuming it's just some nuances with binary representation of numbers.

The question now is how do I know beforehand that something this simple (decrement step by 0.1) is going to run into this problem? Should I always do the (different > epsilon) check instead of (difference = 0) check?
Reply


Messages In This Thread
Coding - Comparison test gone wrong? - by Nikkey - 2011-11-29, 05:40 PM
Coding - Comparison test gone wrong? - by Kalovale - 2011-11-29, 07:27 PM
Coding - Comparison test gone wrong? - by sicnarf - 2011-11-29, 08:12 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)