Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 9 Mar 2017 08:47:55 -0800
From:      Steve Kargl <sgk@troutmask.apl.washington.edu>
To:        "Dennis E. Hamilton" <dennis.hamilton@acm.org>
Cc:        freebsd-numerics@freebsd.org, "'Bruce Evans'" <brde@optusnet.com.au>
Subject:   Re: Bit twiddling question
Message-ID:  <20170309164755.GA34821@troutmask.apl.washington.edu>
In-Reply-To: <000001d298ef$460c42a0$d224c7e0$@acm.org>
References:  <20170308202417.GA23103@troutmask.apl.washington.edu> <20170309173152.F1269@besplex.bde.org> <20170309075236.GA30199@troutmask.apl.washington.edu> <000001d298ef$460c42a0$d224c7e0$@acm.org>

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
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?20170309164755.GA34821>