llvm / llvm/llvm-project

[libcxx] `std::numbers::pi_v<long double>` uses `double` precision instead of `long double` precision

Open
#188,079 2 comments 0 reactions 0 assignees View on GitHub
libc++
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

https://godbolt.org/z/d5rbzM9af (I copy pasted https://github.com/llvm/llvm-project/blob/main/libcxx/include/numbers for this test)

`std::numbers::pi_v` returns the value of `(long double)(3.14159)` instead of `3.14159L`. This means that the value of `std::numbers::NUMBER_v` is **not** the correctly rounded value on targets where `long double` has more precision than `double`.

One fix would be to use `long double` literals, but this problem arises again since `std::numbers::pi_v<__float128>` or etc would be rounded to `long double` precision. So we may have to add these constants for all supported floating point types wider than `long double`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.