C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Proposal to add the circle constant "tau"

From: Thiago Macieira <thiago_at_[hidden]>
Date: Sat, 24 Aug 2024 20:01:51 -0700
On Saturday 24 August 2024 11:28:06 GMT-7 Aaron Franke via Std-Proposals
wrote:
> In order to have the constants grouped so they are evaluated at compile
> time, it would need to be `radius * (2 * std::numbers::pi)`, or simply
> `radius * std::numbers::tau`. Providing a single constant for this
> extremely common value (more commonly needed than pi by itself) will help
> avoid mistakes such as `radius * 2 * std::numbers::pi`.

That's the state of the art today: https://gcc.godbolt.org/z/WEfcfs5vh

But the implementations are not required to do it that way. All four different
implementations you can find in that link above always produce the same result,
even in the case of NaNs and infinities. It just happens the compilers don't
optimise it.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel DCAI Platform & System Engineering

Received on 2024-08-25 03:01:55