Skip to main content

How can I increase the size of my integer variable in PHP?



I need to store a huge number in a PHP variable (it's for a programming contest if you're wondering why). However, if the number is too big, it gets displayed as 6.2995416979471E+77 . Is there a way to store that huge number in PHP?




Comments

  1. integers have a limited size of 32 or 64bit, depending on your architecture.
    floats can store values of any size, but are imprecise.

    If you want to work with giant, precise numbers, use strings and the BC Math extension.

    ReplyDelete
  2. $bigNumber = 1234567890; // etc
    echo number_format($bigNumber, 0);

    ReplyDelete
  3. Have you tried PHP's BCMath arbitrary precision functions? They use strings to represent numbers.

    ReplyDelete

Post a Comment

Popular posts from this blog

Slow Android emulator

I have a 2.67 GHz Celeron processor, 1.21 GB of RAM on a x86 Windows XP Professional machine. My understanding is that the Android emulator should start fairly quickly on such a machine, but for me it does not. I have followed all instructions in setting up the IDE, SDKs, JDKs and such and have had some success in staring the emulator quickly but is very particulary. How can I, if possible, fix this problem?