1. offsetof
#include <stddef.h>
size_t offsetof(type, member);
The macro offsetof() returns the offset of the field member from the start of the structure type.
2. float和int转换
最简单的方法是采用union。
float ff = 123456.0; union{int i; float f;} conv; conv.f = ff; aa[0] = (unsigned short)conv.i; aa[1] = (unsigned short)(conv.i >> 16); printf("%X, %X, %X ", conv.i, aa[0], aa[1]);