note 88288 modified in reserved.constants by danbrown
| From: | danbrown@php.net | Date: | Sat, 13 Jun 2009 01:37:21 +0000 |
| Subject: | note 88288 modified in reserved.constants by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-156832@lists.php.net to get a copy of this message | ||
Another way to determine PHP_INT_MIN:
<?php
define('PHP_INT_MIN', ~PHP_INT_MAX);
?>
It should work always:
MAX for 8bit-signed: 01111111
MIN for 8bit-signed: 10000000
In 32 bits:
php -r"echo (int)base_convert(str_repeat('1', 31), 2, 10) - PHP_INT_MAX;"
0
<?php echo ~(int)base_convert(str_repeat('1', 31), 2, 10); ?>
-2147483648
--was--
Another way to determine PHP_INT_MIN:
define('PHP_INT_MIN', ~PHP_INT_MAX);
It should work always:
MAX for 8bit-signed: 01111111
MIN for 8bit-signed: 10000000
In 32 bits:
php -r"echo (int)base_convert(str_repeat('1', 31), 2, 10) - PHP_INT_MAX;"
0
echo ~(int)base_convert(str_repeat('1', 31), 2, 10);
-2147483648
http://php.net/manual/en/reserved.constants.php