5 #include <refidsmear.h>
8 * we want to test a refid format of:
11 * where x.y.z are 24 bits containing 2 (signed) integer bits
12 * and 22 fractional bits.
18 convertRefIDToLFP(uint32_t r)
24 // printf("%03d %08x: ", (r >> 24) & 0xFF, (r & 0x00FFFFFF) );
26 temp.l_uf = (r << 10); /* 22 fractional bits */
28 temp.l_ui = (r >> 22) & 0x3;
29 temp.l_ui |= ~(temp.l_ui & 2) + 1;
36 convertLFPToRefID(l_fp num)
40 /* round the input with the highest bit to shift out from the
41 * fraction, then keep just two bits from the integral part.
43 * TODO: check for overflows; should we clamp/saturate or just
49 /* combine integral and fractional part to 24 bits */
50 temp = (num.l_ui << 22) | (num.l_uf >> 10);
52 /* put in the leading 254.0.0.0 */
53 temp |= UINT32_C(0xFE000000);
55 // printf("%03d %08x: ", (temp >> 24) & 0xFF, (temp & 0x00FFFFFF) );