C++ Logo

std-proposals

Advanced search

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

From: Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]>
Date: Sat, 5 Mar 2022 20:19:12 -0500
On Sat, Mar 5, 2022 at 9:48 AM Desmond Gold Bongcawel via Std-Proposals <
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://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

I'm familiar with 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". 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.)

–Arthur

Received on 2022-03-06 01:19:25