Use of C99 extra long double math functions after r236148

Bruce Evans brde at optusnet.com.au
Sun Aug 12 23:00:13 UTC 2012


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


More information about the freebsd-numerics mailing list