views:

113

answers:

1

How to write such C# code in Actionscript?

Console.WriteLine(BitConverter.ToDouble(new byte[8] 
            { 0x77, 0xBE, 0x9F, 0x1A, 0x2F, 0x0D, 0x4F, 0x40 }, 0));
+2  A: 

You can rely on the ByteArray to do the conversion for you, but beware of the order of the bytes you write.

var bytes:Array = [0x77, 0xBE, 0x9F, 0x1A, 0x2F, 0x0D, 0x4F, 0x40];
var ba:ByteArray = new ByteArray();
for (var i:int = 7;i>=0;--i) ba.writeByte(bytes[i]);
ba.position = 0;
trace(ba.readDouble());
Patrick