php: What's the equivalent int()
function for bigint type? (int()
cuts big numbers to 2147483647)?
Example:
$bigint1="12312342306A_C243";
$bigint1=(int)$bigint1;//2147483647
but I want it to be 12312342306.
An integer data type is a non-decimal number between -2147483648 and 2147483647 in 32 bit systems, and between -9223372036854775808 and 9223372036854775807 in 64 bit systems. A value greater (or lower) than this, will be stored as float, because it exceeds the limit of an integer.
Zend\Math\BigInteger\BigInteger offers a class to manage arbitrary length integers. PHP supports integer numbers with a maximum value of PHP_INT_MAX , a value defined by your processor architecture and available memory.
The intval() function is an inbuilt function in PHP which returns the integer value of a variable. Parameters: This function accepts two parameters out of which one is mandatory while the other one is optional.
The function intval() gets the integer value of a variable.
I know is old and answered, but for future reference of people looking at this:
UPDATED
The size of an integer is platform-dependent, although a maximum value of about two billion is the usual value (that's 32 bits signed). 64-bit platforms usually have a maximum value of about 9E18, except on Windows prior to PHP 7, where it was always 32 bit. PHP does not support unsigned integers. Integer size can be determined using the constant PHP_INT_SIZE, maximum value using the constant PHP_INT_MAX since PHP 5.0.5, and minimum value using the constant PHP_INT_MIN since PHP 7.0.0.
Source
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With