> I don't think it's a case of trace( ) not calling parseFloat

 

I'm not sure what you're talking about. The explanation is that the decimal-string-to-binary-floating-point-number conversion at compile time and at run time are done by different code in different products and they're not producing the same result down to the last decimal place.

 

Did you file the bug?

 

- Gordon

 


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Boon Chew
Sent: Thursday, March 09, 2006 9:19 AM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] In actionscript, converting from string to number loses precision

 

This actually exists in Flash 8 as well.  And I don't think it's a case of trace( ) not calling parseFloat, I get the same thing when I output it to a textfield.

And it gets better:

stop();
var s:String = "952.85";
var i:Number = parseFloat(s);

// txtResultX are dynamic textbox on stage
txtResult1 = Math.floor(952.85 / 0.05);   // 19057, correct
txtResult2 = Math.floor(i / 0.05);             // 19056, wrong
txtResult3 = Math.floor(i * ( 1 / 0.05));   // 19057, correct

- boon

Gordon Smith <[EMAIL PROTECTED]> wrote:

 

- Gordon

 


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Boon Chew
Sent: Wednesday, March 08, 2006 9:31 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] In actionscript, converting from string to number loses precision

 

Anyone has any idea why it's not possible to convert a string to a number without losing precision?

 

var s:Strin! g = "952.86";
var i:Number = parseFloat(s);
trace(i);
trace(i - 952.86);   // Not zero!

- boon


Yahoo! Mail
Use Photomail to share photos without annoying attachments.

 


Yahoo! Mail
Bring photos to life! New PhotoMail makes sharing a breeze.


--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




Reply via email to