The pi Constants

So, perhaps you are used to thinking in degrees, not radians. How do you convert between the two when you use the above functions? That's as easy as pi! If you have the angle in degrees and one of side lengths, first multiple that angle by pi / 180.0 (either $double-pi or $single-pi) to get radians, and then use that resulting theta in the appropriate function.

There are several engrossing exercises for computing pi, and several novel approaches. The most widely-known approach is to compute the value of the series 4 - 4/3 + 4/5 - 4/7 ... (which takes a very large number of terms to get close to Chuck Moore's find (see below)). Another is to use the Fibonacci numbers (see this article on computing pi using arc-tangents) which become usable in about ten terms.


$double-pi[Constant]

The approximation of pi for double-precision floating-point arithmetic.

Type

<double-float>

Description

The value here is 3.14159265358979323846. Chuck Moore, the inventor of the programming language Forth, chose instead to use 355 / 113 as pi (which is accurate to 3e-7), as computers at the time processed floating point operations too slowly for use in real-time applications.


$single-pi[Constant]

The approximation of pi for single-precision floating-point arithmetic.

Type

<single-float>

Description

This pi is a truncated value of $double-pi.