2 Replies Latest reply on Aug 30, 2009 1:03 AM by dimiorla

    This calculator works only with round numbers

    dimiorla

      I need some help,

      This calculator Works only with round numbers, but is do this 1.9*6 the result is 11.399999999999999 insted of 11.4

      Ware is the problem, can it be solved?

      Theanks in advace,

       

      <?xml version="1.0" encoding="utf-8"?>

      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">

               

      <mx:Script>

      <![CDATA[

       

      private function getTotal():void

      {

      var myInt:int = parseInt(input.text);

      var myFloat:Number = parseFloat(input.text);

      var myNumber:Number = new Number(input.text);

       

      var myInt2:int = parseInt(input2.text);

      var myFloat2:Number = parseFloat(input2.text);

      var myNumber2:Number = new Number(input2.text);

      total.data = (myNumber) * (myNumber2);

      }

       

      ]]>

      </mx:Script>

       

      <mx:TextInput id="input" />

      <mx:TextInput id="input2" />

      <mx:TextInput id="total"/>

      <mx:Button label="Button" click="getTotal();"/>

       

      </mx:Application>