Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php: int() function equivalent for bigint type? (int() cuts strings to 2147483647)

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.

like image 936
Haradzieniec Avatar asked Nov 12 '11 00:11

Haradzieniec


People also ask

How big is int in PHP?

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.

Does PHP have Bigint?

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.

What is intval in PHP?

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.

What is int val?

The function intval() gets the integer value of a variable.


1 Answers

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

like image 156
Manatax Avatar answered Oct 02 '22 05:10

Manatax