Date: Sun, 12 Aug 2012 23:00:13 -0000 From: Bruce Evans <brde@optusnet.com.au> To: Steve Kargl <sgk@troutmask.apl.washington.edu> Cc: Diane Bruce <db@db.net>, John Baldwin <jhb@freebsd.org>, David Chisnall <theraven@freebsd.org>, Stephen Montgomery-Smith <stephen@missouri.edu>, Bruce Evans <bde@freebsd.org>, Bruce Evans <brde@optusnet.com.au>, David Schultz <das@freebsd.org>, Peter Jeremy <peter@rulingia.com>, Warner Losh <imp@bsdimp.com> Subject: Re: Use of C99 extra long double math functions after r236148 Message-ID: <20120720162633.B2162@besplex.bde.org> Resent-Message-ID: <20120812230004.GQ20453@server.rulingia.com> In-Reply-To: <20120720043004.GA7404@troutmask.apl.washington.edu> References: <20120717040118.GA86840@troutmask.apl.washington.edu> <20120717042125.GF66913@server.rulingia.com> <20120717043848.GB87001@troutmask.apl.washington.edu> <20120717225328.GA86902@server.rulingia.com> <20120717232740.GA95026@troutmask.apl.washington.edu> <20120718001337.GA87817@server.rulingia.com> <20120718123627.D1575@besplex.bde.org> <20120719213944.GA21199@server.rulingia.com> <20120719234425.GA6280@troutmask.apl.washington.edu> <20120720130309.P814@besplex.bde.org> <20120720043004.GA7404@troutmask.apl.washington.edu>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 19 Jul 2012, Steve Kargl wrote: > On Fri, Jul 20, 2012 at 02:12:20PM +1000, Bruce Evans wrote: >> On Thu, 19 Jul 2012, Steve Kargl wrote: >> >>> I collected some of the float and double into a cheat sheet. >>> >>> Idioms used in libm with float type: >>> >>> int32_t xsb; >>> u_int32_t hx; >>> >>> GET_FLOAT_WORD(hx, x); >>> >>> /* Get the sign bit of x */ >>> xsb = (hx >> 31) & 1; >> >> Getting it without shifting it (hx & 0x8000) is more efficient and common. >> You don't need to shift it in this example. > > I collected these from msun/src, when I was trying to understand > the magic numbers. I suppose someone should audit the code for > consistency. :-) > > laptop:kargl[219] grep " (hx>>31)&1" *c > e_exp.c: xsb = (hx>>31)&1; /* sign bit of x */ > e_expf.c: xsb = (hx>>31)&1; /* sign bit of x */ The full example of e_exp*.c uses xsb as an index in a table later (not a very good method, but perhaps better than a branch). Bruce
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120720162633.B2162>