Bit twiddling question

Steve Kargl sgk at
Wed Mar 8 20:24:24 UTC 2017

Suppose I have a float 'x' that I know is in the
range 1 <= x <= 0x1p23 and I know that 'x' is 
integral, e.g., x = 12.000.  If I use GET_FLOAT_WORD
from math_private.h, then x=12.000 maps to ix=0x41400000.
Is there a bit twiddling method that I can apply to ix to
unambiguously determine if x is even of odd?

Yes, I know I can do

float x;
int32_t ix;
ix = (int32_t)x;

and then test (ix & 1).  But, this does not generalize to 
the case of long double on a ld128 architecture.  That is,
if I have 1 <= x < 1xp112, then I would need to have

long double x;
int128_t ix;
ix = (int128_t)x;

and AFAICT sparc64 doesn't have an int128_t.


More information about the freebsd-numerics mailing list