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

next in thread | previous in thread | raw e-mail | index | archive | help


> -----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
>=20
> 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 <=3D x <=3D 0x1p23 and I know that 'x' is
> > > integral, e.g., x =3D 12.000.  If I use GET_FLOAT_WORD
> > > from math_private.h, then x=3D12.000 maps to ix=3D0x41400000.
> > > 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.
[orcmid]=20

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.   =20

 - Dennis

[ ... ]




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?000001d298ef$460c42a0$d224c7e0$>