The way you deal with it will depend on what you want to do.

If you want to see is something is "close enough to zero" you subtract them and check the difference

if (Math.abs(i - 952.86)<=0.1){trace("close enough for me")}else {trace("Not the same")};

if (Math.abs(i - 952.86)<=0.0000000001){trace("Really close ")}else {trace("Not yet the same")};

If you use enough leading zeros you will get code that never evaluates to true so do not get wild with leading zeros.

As long as you remember that numbers that are not explicitly cast as integers have to be treated with care, you will be alright.

This problem has been around the computer world for the last 50 years and will be around for some time to come, so we have to just deal with it.


Ron

Yotam Laufer wrote:
-1.13686837721616e-13 is as close to zero as you get matey.... 13 places
after the decimal...

On 07/03/06, Boon Chew <[EMAIL PROTECTED]> wrote:
How do you usually deal with the loss in precision (a bit oxymoron since
floating point can't be exactly represented) when converting a floating
point string to a number?

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


- boon




---------------------------------
Yahoo! Mail
Bring photos to life! New PhotoMail  makes sharing a breeze.
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com




--
Yotam Laufer | Flash Developer | mobile +44 (0) 79 205 17 212 | skype:
ubermutt
------------------------------------------------------------------------

_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to