1

I want Pi to like 100,000,000 decimals/digits.

And variables (well for me) say they have a limit of 67,000,000 bytes. Is there any way around this?

Can you save the first 10,000 characters/digits into one? Can you save it into an array 10,000 in each?

Is there a way?

halfer
  • 19,824
  • 17
  • 99
  • 186
James Andrew
  • 7,197
  • 14
  • 46
  • 62
  • I tried this once and broke stuff. I think the calculation itself was the issue. Splitting it into multiple strings / arrays still requires saving it. Can you post the code you're using to calculate? – hookedonwinter Jun 15 '10 at 18:05
  • Check the top answers here: http://stackoverflow.com/questions/211345/working-with-large-numbers-in-php – Henrik Opel Jun 15 '10 at 18:05
  • I'm just doing $number3 = bcsub($number1, $number2, 10000); -But i want the 10,000 to be 100,000,000 but it doesn't let me -due to variable being to big :P – James Andrew Jun 15 '10 at 18:09

2 Answers2

3

If you're dealing with a buffer of that size, I'd save it to disk somewhere instead of keeping it in memory. Use fwrite and friends to save to a temporary file, and read it back when you're done.

zildjohn01
  • 11,339
  • 6
  • 52
  • 58
1

For dealing with very large numbers of arbitrary sizes you should use the BCMath library. The only limit is the amount of memory available.

rook
  • 66,304
  • 38
  • 162
  • 239