Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
    
Look for "arbitrary precision" and the "--enable-bcmath" compile time switch. –  Daniel Andersson May 13 '12 at 10:30
    
Thanks! I found some functions to work that way now. –  Friend of Kim May 13 '12 at 10:33
    
-1 if you didn't know that 32-bit number is 32 binary digits, and your answer suggests that you didn't, then your question is pathetic. If you'd wondered or meant, what size the number would be in decimal then that'd have been different, but you didn't. But you just wanted to be told that a 32-bit number is 32 binary digits. –  barlop May 13 '12 at 10:42
    
If only I could downvote you on this question a dozen times, it still wouldn't be enough. –  barlop May 13 '12 at 10:45
    
@barlop Actually, I did know about it. However, I didn't know how it works in the "real" world. Super-computers are computing Pi to trillions of decimals, and that's why I wondered if there was a maximum limit as to how many digits you could have in a float value. So it seems like there is a hardware limitation of 32, but if you are smart, you can get around it with software. There is no need to be condescending: "If only I could downvote you on this question a dozen times, it still wouldn't be enough." –  Friend of Kim May 13 '12 at 11:56

1 Answer 1

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.