Actually I think I figured it out....in case anyone else out there is
wondering - if you have a c-style char array holding your hex value,
it will be automatically converted to the host endianess when type
casting into an integer. So then the bytes have to be reconverted
again (network to host) before used. This was a little bit hard to see
at first but now it seems to make sense. ex:

unsigned char your_bytes[4] = 43BE1959;
unsigned long your_integer = (unsigned long) your_bytes;

//this will give 2.70467 E15 which is at first unintuitive, but if you
consider that when casting a char to an int your getting an endianness
change it makes sense

so instead

unsigned long you_integer = ntoh ((unsigned long) your_bytes);

//this will then give the true value of 380.19

-- 
You received this message because you are subscribed to the Google Groups 
"spctools-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/spctools-discuss?hl=en.

Reply via email to