C++ Logo

std-proposals

Advanced search

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

From: Andrey Semashev <andrey.semashev_at_[hidden]>
Date: Sun, 25 Aug 2024 15:09:52 +0300
On 8/25/24 14:08, Mike Reed via Std-Proposals wrote:
> Isn't it possible for a literal constant for tau to be more accurate
> than 2x a literal constant for pi? E.g if my architecture is only
> accurate to 1dp then the literal for pi is 3.1, and 2x that is 6.2. But
> the literal constant for tau would be 6.3, which is more accurate.

You're thinking in decimal. IEEE-754 binary floating point types
representation, which is used practically by every C++ implementation,
uses powers of two for its digit places. That is, the significand is
represented by a binary mantissa, and the point placement within that
mantissa is described by exponent. Multiplying or dividing the number by
a power of two leaves the mantissa unchanged and only changes the
exponent. This means that the precision of the number remains the same.
At least, that's how an implementation is expected to behave.

https://en.wikipedia.org/wiki/IEEE_754

Received on 2024-08-25 12:10:12