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?
Ccna final exam - java, php, javascript, ios, cshap all in one. This is a collaboratively edited question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
Sunday, January 29, 2012
How can I increase the size of my integer variable in PHP?
Tags
php,
Tips For Programmer
Subscribe to:
Post Comments (Atom)
integers have a limited size of 32 or 64bit, depending on your architecture.
ReplyDeletefloats 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.
$bigNumber = 1234567890; // etc
ReplyDeleteecho number_format($bigNumber, 0);
Have you tried PHP's BCMath arbitrary precision functions? They use strings to represent numbers.
ReplyDelete