std.math.TAU
Steven Schveighoffer
schveiguy at yahoo.com
Tue Jul 5 04:15:44 PDT 2011
On Tue, 05 Jul 2011 04:31:09 -0400, James Fisher <jameshfisher at gmail.com>
wrote:
> Hopefully this won't be taken as frivolous. I (and possibly some of you)
> have been convinced by the argument at http://tauday.com/. It's very
> convincing, and I won't rehash it here.
>
> The use of τ instead of π will only become really convenient when one
> does
> not have to preface everything with "let τ = 2π".
>
> For example, in D, in order to think in terms of τ instead of π, one must
> define `enum real TAU = std.math.PI * 2;`, and possibly also TAU_2,
> TAU_4,
> etc.
>
> As well as being a typing inconvenience, I also think things are not that
> easy due to loss of precision (though I'm far from an expert on
> intricacies
> of floating point).
>
> There is an initiative to add TAU to the Python standard library:
> http://www.python.org/dev/peps/pep-0628/
>
> To this end, I suggest adding the constant TAU to std.math, and possibly
> also TAU_2 as an alias for PI, TAU_4 as an alias for PI_2, TAU_8 as PI_4.
>
> In any case, I'd like to know what's necessary in order for me to define
> these constants without loss of precision.
> d
I read an article about this recently, it's definitely interesting. The
one place where I haven't seen it mentioned is what happens when you want
the area of a circle, since that necessarily involves the radius. I'd
guess you'd have to use τ/2 * r^2, but even then, that's one formula vs.
the rest. It's probably a good tradeoff. I can definitely see the
advantage when using radians. Never thought I'd have to re-learn trig
again...
One thing I like about Pi vs Tau is that it cannot be mistaken for a
normal character.
I'm not a floating point expert, but I would expect since floating point
is stored in binary, dividing or multiplying by 2 loses no precision at
all. But I could be wrong...
-Steve
More information about the Digitalmars-d
mailing list