AS3 Hex conversion Weirdness


#1

In AS2:
var Data:Number = 1763478912341234132;
trace ( Data.toString(16) ); //3afdd200

In AS3, the same code outputs: 187922ba3afdd200
Where does the 187922ba come from ?


#2

It’s ok, I found the AS3 version of it from http://snipplr.com/view/60387/as3-decimal-to-hex/:

function decimalToHex($decimal:int, $padding:int = 2):String
{
var hex:String = Number($decimal).toString(16);
while (hex.length < $padding)
{
hex = “0” + hex;
}
return hex.toUpperCase();
}

var decimal:int = 1763478912341234132;
trace("decimal: " + decimal);
var hex:String = decimalToHex(decimal,4); //The 4 mins minimum four characters.
trace("hex: " + hex);


#3

Isn’t 187922ba3afdd200 the correct conversion?


#4

AS2 gives 3afdd200 and the new code I pasted from AS3 gives 3afdd200 so that’s interesting.