Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm making a script that processes PI in PHP. I figured that there is a limit of 13 digits that PHP can process. I tried to find solutions on the internet, and was able to turn this number down, but not up. I think PHP is only 32-bit. Is there a limit on 32-bit frameworks, how many digits they can have in a float value?

share|improve this question
up vote 3 down vote accepted

Yes, on 32-bit systems, with a 32-bit arithmetic unit in the CPU, a 32-bit number is limited to 32 binary digits.

Of course, in most computers, things are not this simple. Software can provide slower support for capabilities that are not in the hardware. How those bits are divided between (for example) exponent and mantissa obviously affects the number of significant digits that can be represented.

The Wikipedia article is a useful introduction.

share|improve this answer
Wikipedia is your friend! – RedGrittyBrick May 13 '12 at 10:34
To calculate the digits of pie, I don't think it'd use an exponent and mantissa. The idea of scientific notation is you get precision (precision is *10^n or in computers *2^n, to get near very large or very tiny numbers, but lose accuracy. To calculate Pi, scientists want 100% accuracy. They wouldn't store an exponent as the exponent would be 0. e.g. Pi would be whatever *2^0. Also, we know the integer part of Pi is 3. For all we care, the very long fraction could be stored the same way as however a huge number is accurately stored. Perhaps some digits here, some digits next to it etc – barlop May 13 '12 at 18:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .