If I have a floating point value, say, 25.81 and want to separate the
first two places beyond the decimal point (.81) from 25.81, I thought
simple subtration would work, but it seems floating points are even less
accurate in Flash than I thought.  I know the are imprecise, but are
they really this bad?

so:

var a = 25.81
var b = Math.floor(a)
var c = a-b
var d = (Math.round((a-b)*100))*.01
trace(a) //25.81 as expected
trace(b) //25 as expected
trace(c) //returns 0.80999...
trace(d) //returns 0.81 - what I want and expect 

Is my last method for var "d" the most pratical, precise, and readable
way to get 0.81 from 25.81?

Jason Merrill
Bank of America  
GT&O Learning & Leadership Development
eTools & Multimedia Team



_______________________________________________
Flashcoders@chattyfig.figleaf.com
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