Boost logo

Boost :

From: Gero Peterhoff (g.peterhoff_at_[hidden])
Date: 2022-08-22 01:05:38

Am 22.08.22 um 02:11 schrieb Proton:
>> Hi Matt,
>> I haven't tried whether clang's bit_cast supports bit fields. There is a problem with your simple implementation:
>> Memory size for long double/float80 can be 10/12/16 bytes depending on platform or compiler option. You didn't take that into account, so bit_cast then fails.
>> That's why I'm working on extended structures for the bitrepresentation for float-types, so that unusual or machine-specific types can also be mapped. These then also include manipulating the individual components and/or checking for special values. For the concrete implementations it would be advantageous to have a stable bit_cast; otherwise I can only use explicit bitpatterns and hope they are (ieee) compatible.
>> This approach has other advantages. These extended structures always deliver correct results, even if the compiler option fast-math/finite-math or something similar is set. This can be used to implement various requirements, e.g. isnan/isinf:
>> - isnan/isinf -> default
>> - isnan_stable/isinf_stable -> correct results also with fast/finite-math etc
>> This can be very useful when implementing math functions.
>> Best, Gero
> Gero,
> What platform does this fail on? I have provided multiple macro enabled definitions for the bit patterns of long doubles on major architectures.

e.g. on x86 gcc (
x86_64 sizeof(long double) == 16
x86_32 sizeof(long double) == 12
This can also be changed with compiler flags, eg with gcc

> Have you run into issues with the implementations of isnan or isinf? We provide a version of fpclassify ( <>)  that yields stable results regardless of the compiler flag like you are looking for.

But fpclassify is an if-else-cascade and not a direct and therefore fast test.
> Matt

Boost list run by bdawes at, gregod at, cpdaniel at, john at