Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 8 Mar 2017 12:24:17 -0800
From:      Steve Kargl <sgk@troutmask.apl.washington.edu>
To:        freebsd-numerics@freebsd.org
Subject:   Bit twiddling question
Message-ID:  <20170308202417.GA23103@troutmask.apl.washington.edu>

next in thread | raw e-mail | index | archive | help
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.

-- 
Steve
20161221 https://www.youtube.com/watch?v=IbCHE-hONow



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20170308202417.GA23103>