Boost logo

Boost :

From: Matt Borland (matt_at_[hidden])
Date: 2023-04-21 11:06:14


Gero,

> 1) copysign uses abs, which is wrong. copysign/signbit may *only* change/check the sign (https://en.cppreference.com/w/cpp/numeric/math/copysign https://en.cppreference.com/w/cpp/numeric/math/signbit)!

I think you are conflating signbit and copysign here. Copysign is to return the magnitude of the first argument (which by definition is the absolute value) with the sign of the second argument. We use signbit in the implementation of this because copysign can be used to manipulate the signs of NaNs.

> 2) In signbit.hpp you implement struct IEEEfN2bits. But these are incomplete:
> - long double can be 16/12/10 bytes depending on platform/compiler option. You do not take this into account.
> - Correct types are already available in boost/math/cstdfloat/cstdfloat_types.hpp.

You will find implementations of IEEEl2bits here https://github.com/boostorg/math/blob/develop/include/boost/math/ccmath/signbit.hpp#L94. They account for 64, 80, and 128 bit long doubles based on LDBL_MANT_DIG and LDBL_MAX_EXP. If for instance you use compiler flags on GCC to alter the size of a long double those macros are changed accordingly.

> PS
> gcc13 is about to be released (https://gcc.gnu.org), so it is high time to support std::floatN_t as well.

Yes, the release of GCC 13 is scheduled for next week. Once it’s available for download I will open issues/PRs to fix any breakages that come from the new types. In the interim I believe, but cannot confirm that if you use a policy that disables promotion you should be fine.

Matt


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk