It is the larger of:
- PHP_INT_MAX and
- The maximum of the contiguous set of integers that can be expressed as a float.
Typical PHP implementations use IEEE 754 for implementing floating point numbers, which has a 53-bit significand, so the typical limit for 32-bit environments is 2⁵³ (0x20000000000000
) and for 64-bit environments, the limit is 2⁶³-1 (0x7fffffffffffffff
).
There’s a trivial solution if you have the PHP gmp extension ( http://php.net/gmp ):
$hexNumber = gmp_strval( gmp_init( $binNumber, 2 ), 16 ) ;
If you have the bc extension (http://php.net/bc ), my (free & open source) WeirdoCustomDigits module will do conversions with arbitrary bases and arbitrary digit characters, without limitation.
If you're simply converting between base 2 and base 16, as with your example, you can get by without bc or gmp. See the source in the WeirdoCustomDigits module for WeirdoCustomDigits::binFromHex() and WeirdoCustomDigits::hexFromBin().