Date: Sat, 24 Aug 2024 18:28:06 +0000 (UTC)
Re: Robin Savonen S?derholm <robinsavonensoderholm_at_[hidden]>:
> It's apparently sometimes used for the golden ratio, but we have phi for that.
> Does it matter that it's used for 300 in https://en.wikipedia.org/wiki/Greek_numerals ?
>
> We already have e and phi which are used for various terms in other
> contexts, but as members of std::numbers they're the well known constants.
> That's what namespaces are for.
Tau is a well-known constant these days. It is the first result on Google for "tau constant": https://www.google.com/search?q=tau+constant
I have not heard of it being used for the golden ratio or the number 300 before. I have heard of the Greek Tau symbol used in other contexts, such as a symbol for turns, a symbol for torque, a symbol for proper time in Einstein's General Relativity, or the Tau elementary particle in physics. However, none of the uses I mentioned are numbers and none could be confused with this value. I would not muddy the waters with unrelated things like the Golden Ratio when it is already widely accepted to use Phi for that: https://www.google.com/search?q=golden+ratio
Re: Phil Endecott <std_proposals_list_at_[hidden]>:
> Regarding "tau", personally I don't like it. If I were reading someone
> else's code and saw tau mentioned I wouldn't confidently know what it meant
The most common way to represent the circle constant is 2 * pi, this is true. However, Tau is rapidly gaining popularity, including in many programming languages.
Re: Thiago Macieira <thiago_at_[hidden]>:
> Divisions and multiplications by powers of 2 are exact in IEEE 754 binary
> floating points. There's no loss of precision in the process nor any precision
> lacking in the result.
Correct, there is nothing preventing users from writing code using the exact value of the circle constant (6.2831... and so on) even without Tau being included in the <numbers> header. However, keep in mind that by this logic, Pi does not need to be included either, because projects/libraries/etc can always define their own constants with the value set to a numeric literal.
The purpose of <numbers> and std::numbers is to provide a central standardized place to retrieve common mathematical constants in order for code to be standardized and more readable. Adding Tau as a constant furthers this goal, by allowing users to replace `(2 * std::numbers::pi)` with `std::numbers::tau`, and avoids misuse such as when programmers forget to include the parenthesis (see below).
Re: Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]>:
> That said, there is a (slight) ergonomic benefit to writing
> radius * std::numbers::tau
> instead of
> radius * 2 * std::numbers::pi
Note that, specifically, `std::numbers::tau` is not a replacement for `2 * std::numbers::pi`, it is a replacement for `(2 * std::numbers::pi)` in parenthesis. Strictly speaking, due to the order of operations, `radius * 2 * std::numbers::pi` results in the same behavior as `(radius * 2) * std::numbers::pi`.
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`.
> It's apparently sometimes used for the golden ratio, but we have phi for that.
> Does it matter that it's used for 300 in https://en.wikipedia.org/wiki/Greek_numerals ?
>
> We already have e and phi which are used for various terms in other
> contexts, but as members of std::numbers they're the well known constants.
> That's what namespaces are for.
Tau is a well-known constant these days. It is the first result on Google for "tau constant": https://www.google.com/search?q=tau+constant
I have not heard of it being used for the golden ratio or the number 300 before. I have heard of the Greek Tau symbol used in other contexts, such as a symbol for turns, a symbol for torque, a symbol for proper time in Einstein's General Relativity, or the Tau elementary particle in physics. However, none of the uses I mentioned are numbers and none could be confused with this value. I would not muddy the waters with unrelated things like the Golden Ratio when it is already widely accepted to use Phi for that: https://www.google.com/search?q=golden+ratio
Re: Phil Endecott <std_proposals_list_at_[hidden]>:
> Regarding "tau", personally I don't like it. If I were reading someone
> else's code and saw tau mentioned I wouldn't confidently know what it meant
The most common way to represent the circle constant is 2 * pi, this is true. However, Tau is rapidly gaining popularity, including in many programming languages.
Re: Thiago Macieira <thiago_at_[hidden]>:
> Divisions and multiplications by powers of 2 are exact in IEEE 754 binary
> floating points. There's no loss of precision in the process nor any precision
> lacking in the result.
Correct, there is nothing preventing users from writing code using the exact value of the circle constant (6.2831... and so on) even without Tau being included in the <numbers> header. However, keep in mind that by this logic, Pi does not need to be included either, because projects/libraries/etc can always define their own constants with the value set to a numeric literal.
The purpose of <numbers> and std::numbers is to provide a central standardized place to retrieve common mathematical constants in order for code to be standardized and more readable. Adding Tau as a constant furthers this goal, by allowing users to replace `(2 * std::numbers::pi)` with `std::numbers::tau`, and avoids misuse such as when programmers forget to include the parenthesis (see below).
Re: Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]>:
> That said, there is a (slight) ergonomic benefit to writing
> radius * std::numbers::tau
> instead of
> radius * 2 * std::numbers::pi
Note that, specifically, `std::numbers::tau` is not a replacement for `2 * std::numbers::pi`, it is a replacement for `(2 * std::numbers::pi)` in parenthesis. Strictly speaking, due to the order of operations, `radius * 2 * std::numbers::pi` results in the same behavior as `(radius * 2) * std::numbers::pi`.
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`.
Received on 2024-08-24 18:28:11