Use of C99 extra long double math functions after r236148
Stephen Montgomery-Smith
stephen at missouri.edu
Sun Aug 12 23:09:02 UTC 2012
On 07/18/2012 10:27 PM, Steve Kargl wrote:
> On Wed, Jul 18, 2012 at 10:05:43PM -0500, Stephen Montgomery-Smith wrote:
>> On 07/18/2012 09:53 PM, Steve Kargl wrote:
>>>
>>> The inexact flag will get raised by the fpu, but you need to
>>> cause the condition. For your 'sqrt(y*y-1) = y' example,
>>> you would do something like 'sqrt(y*y-1) = abs(y) - tiny' where
>>> tiny is much less than abs(y). Search msun/src for inexact
>>> (ie., grep -i inexact msun/src/*.c)
>>>
>>
>> Couldn't you do this instead?
>>
>> #include <fenv.h>
>>
>> feraiseexcept(FE_INEXACT)
>>
>
> I haven't checked, but I suspect you're looking at a speed
> issue. It's faster to let the hardware raise the flag.
> It seems that libm only uses the above in the fuse-multiple-add
> code:
>
> laptop:kargl[206] grep feraise src/*c
> src/s_fma.c: feraiseexcept(FE_INEXACT);
> src/s_fma.c: feraiseexcept(FE_UNDERFLOW);
> src/s_fmal.c: feraiseexcept(FE_INEXACT);
> src/s_fmal.c: feraiseexcept(FE_UNDERFLOW);
> src/s_lround.c: feraiseexcept(FE_INVALID);
>
Still, I think I will use the feraiseexcept function in clog, because
speed isn't an issue when nans are involved. And it does make the code
less obscure.
More information about the freebsd-numerics
mailing list