```Date:      Thu, 9 Mar 2017 08:47:55 -0800
To:        "Dennis E. Hamilton" <dennis.hamilton@acm.org>
Cc:        freebsd-numerics@freebsd.org, "'Bruce Evans'" <brde@optusnet.com.au>
Subject:   Re: Bit twiddling question
```

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
```On Thu, Mar 09, 2017 at 08:07:37AM -0800, Dennis E. Hamilton wrote:
>
> > -----Original Message-----
> > From: owner-freebsd-numerics@freebsd.org [mailto:owner-freebsd-
> > numerics@freebsd.org] On Behalf Of Steve Kargl
> > Sent: Wednesday, March 8, 2017 23:53
> > To: Bruce Evans <brde@optusnet.com.au>
> > Cc: freebsd-numerics@freebsd.org
> > Subject: Re: Bit twiddling question
> >
> > On Thu, Mar 09, 2017 at 05:58:52PM +1100, Bruce Evans wrote:
> > > On Wed, 8 Mar 2017, Steve Kargl wrote:
> > >
> > > > 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?
> > >
> > > I don't know of any good method.
>
> If you are certain about the pre-conditions holding absolutely,
> figure out the power of 2 *float* to add to your value, such
> that the binary point is forced to be at the low-order edge of
> the float word.  This might be a bit faster than casting your
> float to int directly.

Thanks, I'll look into doing the above.  Yes, I'm certain
of the conditions.  See my other posts from earlier today.
I have a way forward.  Optimizations can come later.

--
Steve