tags:

views:

116

answers:

3

I want to save a 11 digit number inside a variable. How can I do this in PHP?

+5  A: 

You could use the BC Math extension. Also, the 64-bit version of PHP uses 64-bit integers natively, so you could just use that if your hardware supports it. (There is no official 64-bit version, as far as I know, so I don't know how reliable it is.)

musicfreak
@Jack says he only wants to save an 11 digit number. Handling it as a string may be a lot less of an overhead.
symcbean
@symcbean: True, but if he wants to do math on that integer, he'll want a library like BC Math. I guess I made an assumption before answering, but I figured he wanted to do more than just store it in a variable.
musicfreak
A: 

Yes, mediumint and bigint is there.

Karthik
I get a parse error when I use bigint or mediumint
Bruce
I don't know what you were referring to, but PHP does not support integers larger than 32 bits on 32-bit platforms. -1
musicfreak
+3  A: 

The GMP library is also worth looking at.

paullb