C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Introducing std::numbers::tau

From: Jens Maurer <Jens.Maurer_at_[hidden]>
Date: Sun, 6 Mar 2022 09:32:33 +0100
On 06/03/2022 02.19, Arthur O'Dwyer via Std-Proposals wrote:
> On Sat, Mar 5, 2022 at 9:48 AM Desmond Gold Bongcawel via Std-Proposals <std-proposals_at_[hidden] <mailto:std-proposals_at_[hidden]>> wrote:
>
> [resent the mail]
>
> I know this is a silly minor addition, but this would help reduce the duplication of writing (std::numbers::pi * 2) wherever they exist in some particular computations such as computing the circumference of the circle.
>
> The constant tau already existed in other programming languages such as C#, rust, etc.
>
>
> https://doc.rust-lang.org/stable/std/f64/consts/constant.TAU.html <https://doc.rust-lang.org/stable/std/f64/consts/constant.TAU.html>
> https://docs.microsoft.com/en-us/dotnet/api/system.math.tau <https://docs.microsoft.com/en-us/dotnet/api/system.math.tau>
> https://stackoverflow.com/questions/13426562/why-does-math-h-define-pi-pi-2-2-pi-but-not-2pi <https://stackoverflow.com/questions/13426562/why-does-math-h-define-pi-pi-2-2-pi-but-not-2pi>
>
> I'm familiar with https://tauday.com/tau-manifesto <https://tauday.com/tau-manifesto> , but still, you're going to have an uphill battle explaining why "tau_v" would be a better name than "twopi_v".

Yes, rationale needed.

> The only obvious benefit of naming it "tau" would be that 100 years from now, when everyone's using tau for all their mathematical needs, C++ won't be ridiculed for having outdated nomenclature that feels like it's stuck in the (400s BC through 2000s). ;)
>
> expression equivalent to:
> 2 * std::numbers::pi_v<T>
>
>
> (For dummies like me who might also be fooled by this at first: No, this is not "shifting in a zero from the right" and thus losing one bit of precision in the mantissa. It's just taking M_PI and increasing the exponent by 1. So this is indeed mathematically correct.)

This rationale is incorrect for implementations not
providing binary floating-point. As far as I understand,
there is no normative requirement for an implementation
to supply binary floating-point; decimal floating-point
(for example) is entirely fine, too.

Thanks,
Jens

Received on 2022-03-06 08:32:38