Tag: 按位 或

整数及其负数的按位OR的目的

我很好奇NaN在IEEE单精度和双精度浮点中的实现和表示,我发现这是“NaN”函数的实现。 即: int isnan(double x) { int32_t hx,lx; // Move lower 32 bits of double to lx, higher 32 to hx. EXTRACT_WORDS(hx,lx,x); // Remove sign bit, since -NaN and NaN are both NaN. hx &= 0x7fffffff; // Equivalent to hx |= (lx != 0). hx |= (u_int32_t)(lx|(-lx))>>31; // Difference is negative iff (hx & 0x7ff00000) […]