Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to parse long value in php?

Need something like intVal() but for bigger numbers, for example: 100001416147426.

Is there a function like this in php? Can't find it.

like image 566
degressor Avatar asked Mar 26 '26 01:03

degressor


1 Answers

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 numbers
  • bccomp — Compare two arbitrary precision numbers
  • bcsqrt Get the square root of an arbitrary precision number
  • ...

On the PHP documentation site there is a small code example by Charles to round a long number!

like image 99
powtac Avatar answered Mar 28 '26 15:03

powtac