note 78598 added to reserved.constants
| From: | josharian at gmail dot com | Date: | Thu, 18 Oct 2007 15:56:50 +0000 |
| Subject: | note 78598 added to reserved.constants | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-131510@lists.php.net to get a copy of this message | ||
@docey:
Unfortunately, that will not work -- PHP will convert (PHP_INT_MAX+1) to a float.
At least on my system, the minimum integer size is -PHP_INT_MAX - 1. I would say that that should be
reliable elsewhere, but PHP ints have known portability issues -- see e.g. http://preview.tinyurl.com/ywh7ya
Confirm this way:
<?php
echo gettype(PHP_INT_MAX) . "\n";
echo gettype(PHP_INT_MAX + 1) . "\n";
echo gettype(-PHP_INT_MAX) . "\n";
echo gettype(-PHP_INT_MAX - 1) . "\n";
echo gettype(-PHP_INT_MAX - 2) . "\n";
?>
On my system this yields:
integer
double
integer
integer
double
It would be nice to have a PHP_INT_MIN, though. Even better would be to have reliable, predictable
data types...
----
Server IP: 69.147.83.197
Probable Submitter: 71.6.18.226
----
Manual Page -- http://www.php.net/manual/en/reserved.constants.php
Edit -- https://master.php.net/note/edit/78598
Del: integrated -- https://master.php.net/note/delete/78598/integrated
Del: useless -- https://master.php.net/note/delete/78598/useless
Del: bad code -- https://master.php.net/note/delete/78598/bad+code
Del: spam -- https://master.php.net/note/delete/78598/spam
Del: non-english -- https://master.php.net/note/delete/78598/non-english
Del: in docs -- https://master.php.net/note/delete/78598/in+docs
Del: other reasons-- https://master.php.net/note/delete/78598
Reject -- https://master.php.net/note/reject/78598
Search -- https://master.php.net/manage/user-notes.php