|
|
Message-ID: <13F146D849AC41A6821080A0307B8796@H270>
Date: Thu, 12 Aug 2021 00:43:36 +0200
From: "Stefan Kanthak" <stefan.kanthak@...go.de>
To: "Szabolcs Nagy" <nsz@...t70.net>,
"Rich Felker" <dalias@...c.org>
Cc: <musl@...ts.openwall.com>
Subject: Re: [PATCH] Properly simplified nextafter()
Szabolcs Nagy <nsz@...t70.net> wrote:
>* Rich Felker <dalias@...c.org> [2021-08-11 13:57:23 -0400]:
>> On Wed, Aug 11, 2021 at 06:50:28PM +0200, Stefan Kanthak wrote:
>> > Rich Felker <dalias@...c.org> wrote:
>> > > static __inline unsigned __FLOAT_BITS(float __f)
>> > > {
>> > > union {float __f; unsigned __i;} __u;
>> > > __u.__f = __f;
>> > > return __u.__i;
>> > > }
>> > >
>> > > #define isnan(x) ( \
>> > > sizeof(x) == sizeof(float) ? (__FLOAT_BITS(x) & 0x7fffffff) > 0x7f800000 : \
>> > > sizeof(x) == sizeof(double) ? (__DOUBLE_BITS(x) & -1ULL>>1) > 0x7ffULL<<52 : \
>> > > __fpclassifyl(x) == FP_NAN)
>> > >
>> > > So, nope.
>> >
>> > GCC typically uses its __builtin_isnan() for isnan(), which doesn't
>> > use integer instructions or reloads:
>>
>> That's only if you #define isnan(x) __builtin_isnan(x)
>
> even then it should use int arithmetics, see below
[...]
> it is also wrong: isnan must not signal for signaling nan.
ARGH: I recommend to read the subject first, then the C standard and
recall how nextafter() is supposed to handle signalling NANs!
<https://pubs.opengroup.org/onlinepubs/9699919799/functions/nextafter.html>
Stefan
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.