Need something like intVal() but for bigger numbers, for example: 100001416147426.
Is there a function like this in php? Can't find it.
Need something like intVal() but for bigger numbers, for example: 100001416147426.
Is there a function like this in php? Can't find it.
You should use BC Math, it is designed to numbers of any size with PHP.
The BC Math extensions offers several mathematic functions like:
bcadd
Add two arbitrary precision numbersbccomp
— Compare two arbitrary precision numbersbcsqrt
Get the square root of an arbitrary precision numberOn the PHP documentation site there is a small code example by Charles to round a long number!
coding standard in the past (since C) has been to follow the number with an L/l $x = 100001416147426L;
This cue's the parser to allocate 64 bits in order to read the number out of the script to compile.
But unless you are running the php x64 this will be useless. Other wise you will have to build it out of a big_number component. Once in a x64 environment intval will automatically expand to a long when exceeding a 32-bit int.
consider
$x = (double) "100001416147426";
var_dump($x);
output:
float(1.0000141614743E+14)