I am trying to multiply to number type variables: The code is something like this::
trace(6.60*6);// !=39.6
var a:Number=6.6;
var b:Number=6;
trace(a*b);// !=39.6
it is not equal to 39.6 in Action Script 3.0 .. instead showing 39.5999999994…
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is a by product of IEEE standard of floating point arithmetic. If you want the real reason why check this paper:
http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html
Most of this comes from Actionscript’s Javascript roots, and in Javascript everything is floating point. There is no diference between ints and floating point math so strange errors crop up that don’t crop up in other languages, but they would if you alway used floats.