8-byte double to 32-bit float
i have problem read binary data serial line, byte byte. no problem fix integers since same size, doubles sent other applications 8 bytes (64 bits), whereas float (or double) in arduino 32 bits.
the data read little endian , ieee754 standard, it's described @ http://en.wikipedia.org/wiki/double_precision_floating-point_format. have not succeded in converting, thought should ask here if has function can or knows can more information. you?
i not care loosing decimals @ end; not work nuclear safety.
the data read little endian , ieee754 standard, it's described @ http://en.wikipedia.org/wiki/double_precision_floating-point_format. have not succeded in converting, thought should ask here if has function can or knows can more information. you?
i not care loosing decimals @ end; not work nuclear safety.
looking @ 2 formats on wikipedia, 32 bit floats have: 1 sign bit, 8 exponent , 23 fraction bits.
whereas 64 bit floats have: 1 sign bit, 11 exponent , 52 fraction bits.
i might wrong this, guess if packed sign bit of 64bit float sign bit of 32bit float , significant 8 bits of 64bit floats exponent 32bit float's exponent bit positions , same significant bits of fraction part, might work!
what bit hazy (my c's not good) how packing. guess, might able set bits in int[2] array (32 bit) , assign double variable it?
something (although may talking java):
int rawbits = int[2];
// loops bit copying
double value = (double)rawbits;
hope @ least points in right direction.
si.
whereas 64 bit floats have: 1 sign bit, 11 exponent , 52 fraction bits.
i might wrong this, guess if packed sign bit of 64bit float sign bit of 32bit float , significant 8 bits of 64bit floats exponent 32bit float's exponent bit positions , same significant bits of fraction part, might work!
what bit hazy (my c's not good) how packing. guess, might able set bits in int[2] array (32 bit) , assign double variable it?
something (although may talking java):
int rawbits = int[2];
// loops bit copying
double value = (double)rawbits;
hope @ least points in right direction.
si.
Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > 8-byte double to 32-bit float
arduino
Comments
Post a Comment