Thursday Night

Paul Betts’s personal website / blog / what-have-you

The strangest definition of Pi I’ve ever seen

I came across this while reading through some of the Xcode examples, in DemonstrateFFT.c:

static const float_t TwoPi = 0×3.243f6a8885a308d313198a2e03707344ap1;

While completely unreadable, this is actually one of the most accurate ways to specify this number on a computer, and is (in my opinion) pretty damn clever. Bonus points to anyone who can explain why this works, and why something that’s ~3 is in fact equal to 2x Pi.

Free hint: Check out IEEE 754

Written by Paul Betts

April 10th, 2008 at 12:49 pm

Posted in Programming