Take the 2-minute tour ×

I've two variable of type Number but the sum of them is not correct.

This is my scenario:

var a:Number = 1.1;
var b:Number = 2.2;
var c:Number = a + b;

result of c is 3.3000000003 instead 3.3

How can I resolve this issue?

Obviously the precision of 'a' and 'b' in the sample is 1 number after comma, but can be several.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

This expected behaviour. It is actually pretty hard to express certain numbers in the binary number system. A close aprox. wil result in:

1.00011001100110011001100110011001... (1.09999..)

sadly 1.2 is equally hard:

1.00110011001100110011001100110011... (1.19999..)

as you might note the 1100 keeps repeating. Just like it isn't possible to express 1/3 in the decimal system.

The solution could be to use less precision by rounding the c.

share|improve this answer
Thank you for your response. I must change my approach because I can't lose precision. –  Joe Taras Jul 13 '13 at 12:13
add comment

Your Answer


