4 Replies Latest reply on Sep 2, 2006 6:34 PM by kglad

# why 3.78-3=0.78 but 3000.78-3000 !=0.78?????

just found an intreesting thing,

trace (3000.78-3000) // 0.7800000000002
trace (3.78-3) // 0.78

Why???????
• ###### 1. Re: why 3.78-3=0.78 but 3000.78-3000 !=0.78?????
binary computers do not use decimal representation of numbers. so, you will see rounding errors if you look closely enough.
• ###### 2. Re: why 3.78-3=0.78 but 3000.78-3000 !=0.78?????
news:edaikj\$b3g\$1@forums.macromedia.com...
> binary computers do not use decimal representation of
> numbers. so, you will see rounding errors if you look closely
> enough.

To add to what kglad said, this holds true across the board on binary
computers. In other words, this is not a bug in Flash: it's a fact of life
in dealing with the sorts of computers we all use. You'll see the same
rounding errors in JavaScript, Java, C#, Perl, PHP, etc., etc., etc., -- to
a greater or lesser extent, depending on the degree of accuracy to which
numbers are stored in that language.

David Stiller