Main Index : Reference :
[float] mem2liee([bytes] mem,[int] pos,[int] byteorder)
mem is a byte array.pos is the position within mem.byteorder is either big endian or little endian.
mem2liee() converts 8 bytes from position pos in the byte array mem as a 64 bit IEE double float and returns the result as a float value. The byte ordering is decided by the value of the byteorder parameter:
| Value | Platform | Byte ordering |
GE_MOTOROLA |
Motorola | big endian |
GE_INTEL |
Intel | little endian |
An IEE double float consists of 1 sign bit (0 = positive and 1 = negative), 11 bits for the exponent (unsigned but biased with 1023) and 52 bits for the mantissa (a binary fraction with an implied leading 1).
Remember: The first element of a byte array is at position 0.
// Outputs "18461.947266"
var mem = new(bytes,8);
mem[0]=0x40;
mem[1]=0xD2;
mem[2]=0x07;
mem[3]=0x7C;
mem[4]=0xA0;
mem[5]=0x00;
mem[6]=0x00;
mem[7]=0x00;
var motorola = mem2liee(mem,0,GE_MOTOROLA);
println(motorola);
// Outputs "18461.947266"
var mem = new(bytes,8);
mem[0]=0x00;
mem[1]=0x00;
mem[2]=0x00;
mem[3]=0xA0;
mem[4]=0x7C;
mem[5]=0x07;
mem[6]=0xD2;
mem[7]=0x40;
var intel = mem2liee(mem,0,GE_INTEL);
println(intel);