RE: Number Multiplication AS3

2018-02-05 Thread Σπύρος Αγγελόπουλος
Eric, Thanks for the quick response. Spiros -Original Message- From: Erik J. Thomas [mailto:e...@linqto.com] Sent: Friday, February 2, 2018 6:49 PM To: users@flex.apache.org Subject: Re: Number Multiplication AS3 You can sort of fix this issue by rounding, but it just hides the

Re: Number Multiplication AS3

2018-02-02 Thread Erik J. Thomas
You can sort of fix this issue by rounding, but it just hides the issue and should not be used for financial applications: var setPrecision:Function = function(number:Number, precision:int) { precision = Math.pow(10, precision); return Math.round(number * precision)/precision; } var number:Num

Re: Number Multiplication AS3

2018-02-02 Thread Erik J. Thomas
The Number data type, when including a decimal point is a binary floating point number and binary floating point math can result in rounding errors like yours. https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html#680

Number Multiplication AS3

2018-02-02 Thread Σπύρος Αγγελόπουλος
Hi Everyone, Can anyone verify the results of calculation below ? var n1:Number=18.9; var n2:Number=100.0; var n3:Number=n1*n2; //1889.8 is it bug ? thanks spiros