note 74767 modified in function.intval by danbrown
| From: | danbrown@php.net | Date: | Thu, 16 Sep 2010 15:10:27 +0000 |
| Subject: | note 74767 modified in function.intval by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-172641@lists.php.net to get a copy of this message | ||
Since integers are stored on multiple bytes in the memory in binary format, once an signed long
integer reaches the maximum value of 2147483646 (which is the maximum value that 8 bits of memory,
size of a long int, can store, binary-wise), atleast on C/C++ the number starts to roll back, going
gradually to ...45, ...45 and eventually reaching a negative value. Some REALLY large values will
return -1, probably because PHP simply rejects the number, though I'm not sure why.
For further info:
http://www.rwc.uc.edu/koehler/comath/13.html
--was--
Indeed, as stated by David, since integers are stored on multiple bytes in the memory in binary
format, once an signed long integer reaches the maximum value of 2147483646 (which is the maximum
value that 8 bits of memory, size of a long int, can store, binary-wise), atleast on C/C++ the
number starts to roll back, going gradually to ...45, ...45 and eventually reaching a negative
value. Some REALLY large values will return -1, probably because PHP simply rejects the number,
though I'm not sure why.
For further info:
http://www.rwc.uc.edu/koehler/comath/13.html
http://php.net/manual/en/function.intval.php