Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does PHP have a data type bigger than int?

Tags:

php

I want to save a 11 digit number inside a variable. How can I do this in PHP?

like image 897
Bruce Avatar asked Apr 26 '10 05:04

Bruce


People also ask

How big is an int in PHP?

PHP Integers 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.

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 the difference between int and integer in PHP?

The major difference between an Integer and an int is that Integer is a wrapper class whereas int is a primitive data type. An int is a data type that stores 32-bit signed two's complement integer whereas an Integer is a class that wraps a primitive type int in an object.

How many bytes is an int PHP?

PHP int size is platform-dependent, and it seems to be 8 bytes on our 64-bit boxes. Yes, the very same ones where C/C++ int is 4 bytes, you know.


2 Answers

The 64-bit version of PHP uses 64-bit integers natively, so that's plenty of bits for an 11-digit number. That said, if you need larger integers, I would use the BC Math extension.

like image 105
Sasha Chedygov Avatar answered Oct 04 '22 20:10

Sasha Chedygov


The GMP library is also worth looking at.

like image 36
paullb Avatar answered Oct 04 '22 20:10

paullb