Learn math with flash, flex or javascript!

On December 20, 2007, Flash / Flex - 1 Comment

Flex / Flash has a neat feature: doing math for you.

So when you want to know what 0.1 + 0.2 is, you don’t need your calculator, just use flex. The result: 0.30000000000000004.

WTF is that about?

I’m currently trying to find out a fix for this. ATM the only workaround is doing a

?View Code ACTIONSCRIPT
var x:Number = 0.1 + 0.2
Math.round(x*10) / 10

How hard is it to add to two numbers and give the correct result?

or of course

?View Code ACTIONSCRIPT
var x:Number = (0.1 + 0.2).toFixed(1)

Works for actionscript as well as JavaScript

By the way, it’s not only 0.3 which is causing problems. more…