Get as close to pi as you can Your job is to write a program to find the closest number to PI.

Let me clarify.

You will first choose a number type. Let us say you choose Integer (in an actual answer, you cannot). Your program would then have to generate an integer that is closed to PI. For Integers, this would be 3. Not 4; 3.

For every allowed number type, there will be one and only one closest number, as you will see.


Select your number type. It should only be able to represent rational numbers. You can not make up your own number types. Float or Double is recommended.
Your program will generate a number ctp for "close to PI" (I am just calling it that; you don't have to). 223/71 &lt; ctp &lt; 22/7 must be true (this is why you can't choose Integers). Also, ctp must be the closet number to PI in its number type (although see bonus).
No importing libraries for mathematical functions, operations, etc... (although types are allowed as long, as it obeys #1).
You must somehow output ctp.
You also may not hard code any number (in any type) that uses at least half the precision of your chosen number type.


Bonus: If you use a data type with a precision that depends on machine resources, and it still generates the most accurate approximation possible for any given machine, you can take the pith root of your score.
Note: If you code may actually exhaust machine resources, put a warning in. That way people know to use virtual machines to check it (or just check it with their minds).

This is code golf, so shortest program in bytes wins!

Note: The point of this challenge is not just to be another pi calculation challenge. You have to work at the limits of your number type, where all calculations can have detrimental rounding errors. You are doing maximum-precision computing. This is not the same as just outputting a large number of digits.
C++ 158 chars
#include&lt;iostream&gt;
#include&lt;iomanip&gt;
int main(){double p=0;for(long long l=1;l&gt;0;l+=2){p+=(double)4/l;l+=2;p-=(double)4/l;}std::cout&lt;&lt;std::setprecision(30)&lt;&lt;p;}

Simply calculates pi by brute force until my computer can't store the number to divide 4 by.
I got to 3.1415926535792384 before I killed it. The highlighted part is what is off; it should have been 3.1415926535897932.  Eventually, it would have got there.