Problems? Is your data what you think it is?  
PerlMonks 
Re: Re: Re: .999999... == 1? (Somewhat OT)by Sherlock (Deacon) 
on Jul 25, 2001 at 05:11 UTC ( #99534=note: print w/replies, xml )  Need Help?? 
This is really what I was hoping someone would come up with. I expected the barrage of mathematical proofs that prove, without a doubt the .9 repeating is indeed equal to 1. However, in a computer, you can't repeat forever. This concept, although true in the word of theoretical mathematics, does not hold true in the world of computers. Attempt this simple script: You'll notice that these two numbers are indeed unequal. You're probably thinking big deal, obviously, $num1 doesn't repeat forever so they shouldn't be equal. Try the script again, but add a single 9 to the end of $num1. You should find the results more interesting. (I'm by no means a Perl guru and am not sure if this will work the same from one Perl installation to another. I am using Perl 5.6.1 on a Win32 platform.) In that case, the two values, even though $num1 still does not repeat forever, are considered equal. What I had come up with, as a refutation to the argument, was that whether .9 repeating is equal to 1 is dependent upon your context. In a mathematical world, it is obviously true. Within a computer, however, it is an entirely different case.  Sherlock Update: Please note, I am not attempting to say that .9 repeating is not equal to 1 simply because a computer can't represent .9 repeating. I was simply trying to point out that there is some level of discrepency between theoretical mathematics and the mathematics done in a computer/calculator. I was really just hoping this post would cause a few of you (and myself) to think about how you use floating point numbers and make you more aware of the rounding errors that can take place. Skepticism is the source of knowledge as much as knowledge is the source of skepticism.
In Section
Meditations

