Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Working with large numbers without GMP

Status
Not open for further replies.

scorpion4377

Programmer
Joined
Apr 11, 2005
Messages
13
Location
US
Since PHP can't compute anything with large numbers, and my server doesn't have GMP installed, I made a few quick functions that can add, multiply, and find the factorials of large numbers.

With my function, the exact value of 51! can be evaluated in 3 seconds.

Of course, since I rushed through the functions, only positive whole numbers are supported. (Not to mention, I haven't made a function to subtract or to divide, and its slow compared to GMP.)

Is there a way I can make PHP work with large numbers without GMP? If not, I will work on making my functions a little better.
 
Are you running PHP on a Unix-like OS? Perhaps you have bc available to be run as an external program.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top