3 Replies Latest reply on Feb 9, 2011 6:00 AM by Ned Murphy

# Problem in Math library in flash

Hello to all;

My name is Ammar Tayeem, this is the first post in this forum.

Yesterday I got a problem with me in the process of calculation in a flash in ActionScript 3, the problem appear in the following Code (When make a multiplication operation with decimal fractions):

stop();
function init():void
{
try1_1_txt.text = "2";
try1_2_txt.text = "0.3";

try2_1_txt.text = "3";
try2_2_txt.text = "0.2";

Result_1_txt.text = String(Number(try1_1_txt.text) * Number(try1_2_txt.text));
Result_2_txt.text = String(Number(try2_1_txt.text) * Number(try2_2_txt.text));

trace("2 * 0.3 = " ,2 * 0.3);
trace("3 * 0.2 = " ,3 * 0.2);
trace("(2 * 0.3)==(3 * 0.2) = " ,(2 * 0.3)==(3 * 0.2))

}

init();

//**************************************************************************************** ***********************************

OUTPUT:

2 * 0.3 =  0.6
3 * 0.2 =  0.6000000000000001
(2 * 0.3) == (3 * 0.2) =  false

//**************************************************************************************** ***********************************

The result is a wrong and illogical.

I hope you can answer and thank you all