flex - AS3 adding 1 (+1) not working on string cast to Number? -
just learning as3 flex. trying this:
var somenumber:string = "10150125903517628"; //this actual number noticed issue var result:string = string(number(somenumber) + 1);
i've tried different ways of putting expression , no matter seem result equal 10150125903517628 rather 10150125903517629
anyone have ideas??! thanks!
all numbers in javascript/actionscript double-precision ieee-754 floats. these use 64-bit binary number represent decimal, , have precision of 16 or 17 decimal digits.
you've run against limit of format 17-digit number. internal binary representation of 10150125903517628 no different of 10150125903517629 why you're not seeing difference when add 1.
if, however, add 2 (should?) see result 10150125903517630 because that's enough of "step" internal binary representation change.
Comments
Post a Comment