rfc:integer_semantics

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
rfc:integer_semantics [2014/08/19 22:35] – clarity array keys ajfrfc:integer_semantics [2014/09/14 22:46] – v0.2.2 - Added examples ajf
Line 1: Line 1:
 ====== PHP RFC: Integer Semantics ====== ====== PHP RFC: Integer Semantics ======
-  * Version: 0.2.1+  * Version: 0.2.2
   * Date: 2014-08-19   * Date: 2014-08-19
   * Author: Andrea Faulds <ajf@ajf.me>   * Author: Andrea Faulds <ajf@ajf.me>
-  * Status: Draft+  * Status: In Voting
   * First Published at: http://wiki.php.net/rfc/integer_semantics   * First Published at: http://wiki.php.net/rfc/integer_semantics
  
Line 18: Line 18:
   - Left bitwise shifts by a number of bits beyond the bit width of an integer will always result in 0, even on CPUs which wrap around   - Left bitwise shifts by a number of bits beyond the bit width of an integer will always result in 0, even on CPUs which wrap around
   - Right bitwise shifts by a number of bits beyond the bit width of an integer will always result in 0 or -1 (depending on sign), even on CPUs which wrap around   - Right bitwise shifts by a number of bits beyond the bit width of an integer will always result in 0 or -1 (depending on sign), even on CPUs which wrap around
 +
 +==== Examples ====
 +
 +For all "was" results, these are only on my machine, as they would differ across platforms. All "now" results are the same on all platforms.
 +
 +<code php>
 +// Was: int(-9223372036854775808)
 +// Now: int(0)
 +var_dump((int)NAN);
 +// Was: int(-9223372036854775808)
 +// Now: int(0)
 +var_dump((int)INF);
 +// Was: int(4611686018427387904)
 +// Now: bool(false) and E_WARNING
 +var_dump(1 << -2);
 +// Was: int(8)
 +// Now: int(0)
 +var_dump(8 >> 64);
 +</code>
  
 ===== Rationale ===== ===== Rationale =====
Line 49: Line 68:
 ===== Patches and Tests ===== ===== Patches and Tests =====
  
-work-in-progress patch is here: https://github.com/TazeTSchnitzel/php-src/compare/php:master...TazeTSchnitzel:integer_semantics+pull request is here: https://github.com/php/php-src/pull/781
  
 The patch is working and has tests, but code review would be appreciated. The patch is working and has tests, but code review would be appreciated.
Line 58: Line 77:
   - a link to the git commit(s)   - a link to the git commit(s)
   - a link to the PHP manual entry for the feature   - a link to the PHP manual entry for the feature
 +
 +===== Vote =====
 +
 +As this is a language change, a 2/3 majority is required.
 +
 +Voting started 2014-09-14 and ends 2014-09-21.
 +
 +<doodle title="Accept the integer semantics RFC and merge patch into master?" auth="ajf" voteType="single" closed="false">
 +   * Yes
 +   * No
 +</doodle>
  
 ===== References ===== ===== References =====
Line 68: Line 98:
 ===== Changelog ===== ===== Changelog =====
  
 +  * v0.2.2 - Added examples
   * v0.2.1 - Open Questions/Possible Future Scope added   * v0.2.1 - Open Questions/Possible Future Scope added
   * v0.2 - Dropped zend_parse_parameters change, fixed left shift too   * v0.2 - Dropped zend_parse_parameters change, fixed left shift too
   * v0.1.1 - Introduction added   * v0.1.1 - Introduction added
   * v0.1 - Initial version   * v0.1 - Initial version
rfc/integer_semantics.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1