flex - ActionScript 3.0 integer overflow? -
i have old air file works fine. tried recompile resulting airfile buggy.
after digging in code, found @ place strings parsed ints, , resulting int not correspond string. made simple actionscript file , executed code:
var test:int = parseint("3710835714");
and variable have value
-584131582
so looks overflow. i'm surprised air file have (which didn't compile myself) runs fine. wonder - internal representation of int somehow depend on version of flex or air sdk libraries 1 using compiling?
//edit: seems boils down test:
var obj:object = new object(); obj.val="3710835714"; var test1:boolean = (obj.val==-584131582); var test2:boolean = (int(obj.val)==-584131582);
this evaluates me to
test1=false; test2=true;
however - old air file seems evaluate both cases true. how can be?
it happening due give number exceeds actionsscript int limit
the int data type stored internally 32-bit integer , comprises set of integers -2,147,483,648 (-231) 2,147,483,647 (231 - 1),
and number 3,710,835,714 exceeds 1563352067
but parse result shows compiler considering uint, max limit 4,294,967,295 i.e
-584131581 = 3,710,835,714 - 4,294,967,295
you should use uint or number big whole-numbers/integers
this blog may helps you
actionscript 3 number data type problem long integer values
hopes works
Comments
Post a Comment