From owner-freebsd-numerics@freebsd.org Thu Mar 9 16:48:07 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 EA4CBD05E57 for ; Thu, 9 Mar 2017 16:48:07 +0000 (UTC) (envelope-from sgk@troutmask.apl.washington.edu) Received: from troutmask.apl.washington.edu (troutmask.apl.washington.edu [128.95.76.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "troutmask", Issuer "troutmask" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id CE8BBE48 for ; Thu, 9 Mar 2017 16:48:07 +0000 (UTC) (envelope-from sgk@troutmask.apl.washington.edu) Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.15.2/8.15.2) with ESMTPS id v29GltjP034945 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 9 Mar 2017 08:47:55 -0800 (PST) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.15.2/8.15.2/Submit) id v29GltIP034944; Thu, 9 Mar 2017 08:47:55 -0800 (PST) (envelope-from sgk) Date: Thu, 9 Mar 2017 08:47:55 -0800 From: Steve Kargl To: "Dennis E. Hamilton" Cc: freebsd-numerics@freebsd.org, "'Bruce Evans'" Subject: Re: Bit twiddling question Message-ID: <20170309164755.GA34821@troutmask.apl.washington.edu> Reply-To: sgk@troutmask.apl.washington.edu References: <20170308202417.GA23103@troutmask.apl.washington.edu> <20170309173152.F1269@besplex.bde.org> <20170309075236.GA30199@troutmask.apl.washington.edu> <000001d298ef$460c42a0$d224c7e0$@acm.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <000001d298ef$460c42a0$d224c7e0$@acm.org> User-Agent: Mutt/1.7.2 (2016-11-26) 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:48:08 -0000 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 > > 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