From owner-freebsd-numerics@freebsd.org Thu Mar 9 16:07:52 2017 Return-Path: Delivered-To: freebsd-numerics@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 00EC1D05FE6 for ; Thu, 9 Mar 2017 16:07:51 +0000 (UTC) (envelope-from dennis.hamilton@acm.org) Received: from nov-007-i623.relay.mailchannels.net (nov-007-i623.relay.mailchannels.net [46.232.183.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6C4851D4C for ; Thu, 9 Mar 2017 16:07:49 +0000 (UTC) (envelope-from dennis.hamilton@acm.org) X-Sender-Id: a2hosting|x-authuser|himself@orcmid.com Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id CA4B9120959; Thu, 9 Mar 2017 16:07:39 +0000 (UTC) Received: from a2s42.a2hosting.com (unknown [100.96.135.39]) by relay.mailchannels.net (Postfix) with ESMTPA id 2C4CB12458D; Thu, 9 Mar 2017 16:07:39 +0000 (UTC) X-Sender-Id: a2hosting|x-authuser|himself@orcmid.com Received: from a2s42.a2hosting.com (a2s42.a2hosting.com [172.20.61.168]) (using TLSv1 with cipher DHE-RSA-AES256-SHA) by 0.0.0.0:2500 (trex/5.7.32); Thu, 09 Mar 2017 16:07:39 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: a2hosting|x-authuser|himself@orcmid.com X-MailChannels-Auth-Id: a2hosting X-Madly-Fearful: 530ad3b634e42515_1489075659565_2445266865 X-MC-Loop-Signature: 1489075659564:3093905383 X-MC-Ingress-Time: 1489075659564 Received: from 75-172-39-61.tukw.qwest.net ([75.172.39.61]:56458 helo=Astraendo2) by a2s42.a2hosting.com with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.87) (envelope-from ) id 1cm0bJ-003Rx9-HF; Thu, 09 Mar 2017 11:07:38 -0500 Reply-To: From: "Dennis E. Hamilton" To: Cc: "'Bruce Evans'" , References: <20170308202417.GA23103@troutmask.apl.washington.edu> <20170309173152.F1269@besplex.bde.org> <20170309075236.GA30199@troutmask.apl.washington.edu> In-Reply-To: <20170309075236.GA30199@troutmask.apl.washington.edu> Subject: RE: Bit twiddling question Date: Thu, 9 Mar 2017 08:07:37 -0800 Organization: NuovoDoc Message-ID: <000001d298ef$460c42a0$d224c7e0$@acm.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQI9VYS4o4iHSjhMB3OB5vywod5c4QGeZGK/Ad8U0Yqgmz9bkA== Content-Language: en-us X-AuthUser: himself@orcmid.com X-BeenThere: freebsd-numerics@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Discussions of high quality implementation of libm functions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Mar 2017 16:07:52 -0000 > -----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 > 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 [ ... ]