On the problem of PHP binary bit length

system and PHP versions

  • system: Centos 64-bit
  • PHP 7.2

URL: http://php.net/manual/en/func.

PHP Code:

<?php

    $a = PHP_INT_SIZE;
    $b = PHP_INT_MAX;
    $c = PHP_INT_MIN;

    echo "\$a:", $a . "\n";
    echo "\$b:", $b . "\n";
    echo "\$c:", $c . "\n\n";

    echo "\$b:" . decbin($b) . "\n";
    echo "\$c:" . decbin($c) . "\n";

output result:

$a:8
$b:9223372036854775807
$c:-9223372036854775808

$b:111111111111111111111111111111111111111111111111111111111111111
$c:1000000000000000000000000000000000000000000000000000000000000000

problem description:

  • in 64-bit system, the maximum integer value is 9223372036854775807, and the minimum integer value is-9223372036854775808,
  • The binary of the minimum value of
  • is 64 bits, and the 1 of the highest bit is a negative number.
  • Why is the maximum binary 63 bits? Did you omit the first 0?

Thank you for the answer

Dec.27,2021
The maximum value of

integer is actually 64 bits, that is, 09223372036854775807, omitting the first 0

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b38f32-4edbc.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b38f32-4edbc.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?