From owner-freebsd-numerics@freebsd.org Wed Mar 8 20:24:24 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 9C3D4D030DE for ; Wed, 8 Mar 2017 20:24:24 +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 82D4419E7 for ; Wed, 8 Mar 2017 20:24:24 +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 v28KOHwU023196 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Wed, 8 Mar 2017 12:24:17 -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 v28KOHBY023195 for freebsd-numerics@freebsd.org; Wed, 8 Mar 2017 12:24:17 -0800 (PST) (envelope-from sgk) Date: Wed, 8 Mar 2017 12:24:17 -0800 From: Steve Kargl To: freebsd-numerics@freebsd.org Subject: Bit twiddling question Message-ID: <20170308202417.GA23103@troutmask.apl.washington.edu> Reply-To: sgk@troutmask.apl.washington.edu MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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: Wed, 08 Mar 2017 20:24:24 -0000 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? Yes, I know I can do float x; int32_t ix; ix = (int32_t)x; and then test (ix & 1). But, this does not generalize to the case of long double on a ld128 architecture. That is, if I have 1 <= x < 1xp112, then I would need to have long double x; int128_t ix; ix = (int128_t)x; and AFAICT sparc64 doesn't have an int128_t. -- Steve 20161221 https://www.youtube.com/watch?v=IbCHE-hONow