What do you mean by converting?
- casting*:
(int) $float
or intval($float)
- truncating:
floor($float)
(down) or ceil($float)
(up)
- rounding:
round($float)
- has additional modes, see PHP_ROUND_HALF_...
constants
*: casting has some chance, that float values cannot be represented in int (too big, or too small), f.ex. in your case.
PHP_INT_MAX
: The largest integer supported in this build of PHP. Usually int(2147483647).
But, you could use the BCMath, or the GMP extensions for handling these large numbers. (Both are boundled, you only need to enable these extensions)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…