https://en.wikipedia.org/wiki/Double-precision_floating-point_format
如果对不包括特殊值情况(如无穷大、NAN等)的浮点类型数组进行基数排序,通常使用从符号和幅值到“二的补码”的转换。示例C宏在64位符号和幅值之间转换为无符号long long(64位无符号整数)并返回。注意,这会导致负零的转换符号和幅值小于正零的转换符号和幅值。
// converting doubles to unsigned long long for radix sort or something similar
// note -0 converted to 0x7fffffffffffffff, +0 converted to 0x8000000000000000
// -0 is unlikely to be produced by a float operation
#define SM2ULL(x) ((x)^(((~(x) >> 63)-1) | 0x8000000000000000ull))
#define ULL2SM(x) ((x)^((( (x) >> 63)-1) | 0x8000000000000000ull))