C++ Logo

std-discussion

Advanced search

Re: SG6] precision of functions in cmath

From: Hans Åberg <haberg_1_at_[hidden]>
Date: Thu, 31 Oct 2024 11:05:58 +0100
The fixed width floating-point types of ISO 60559 are available in C++23 [1], but the support for std::float128_t in terms of other facilities is poor. The type long double may be 80-bit floats padded to 128 bits (as in case of the GCC I use). Then converting std::float128_t back and forth to long double loses precision.

1. https://en.cppreference.com/w/cpp/types/floating-point


> On 24 Oct 2024, at 23:21, Julien Villemure-Fréchette via Std-Discussion <std-discussion_at_[hidden]> wrote:
>
> AFAIK precise semantics of floating point operations and how the floating point types are implemented is implementation defined, and typically defers to some floating point standard.
>
> If your C++ implementation (compiler) implements ISO/IEC 60559 floating point arithmetic, which is almost always the case, then all operations on floating point types, wether builtin or from Numerics Library (cmath, complex, etc) are defined in that standard. Support for ISO/IEC 60559 can be queried in numeric_limits.
>
> Julien V.

Received on 2024-10-31 10:06:20