rfc:integer_semantics
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
rfc:integer_semantics [2014/08/19 20:22] – ajf | rfc: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 | + | * Version: 0.2.2 |
* Date: 2014-08-19 | * Date: 2014-08-19 | ||
* Author: Andrea Faulds < | * Author: Andrea Faulds < | ||
- | * Status: | + | * Status: |
* First Published at: http:// | * First Published at: http:// | ||
Line 15: | Line 15: | ||
- Instead of being undefined and platform-dependant, | - Instead of being undefined and platform-dependant, | ||
- | - Bitwise shifts by negative numbers of bits will be disallowed | + | - Bitwise shifts by negative numbers of bits will be disallowed |
- 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 " | ||
+ | |||
+ | <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); | ||
+ | </ | ||
===== Rationale ===== | ===== Rationale ===== | ||
Line 37: | Line 56: | ||
===== Unaffected PHP Functionality ===== | ===== Unaffected PHP Functionality ===== | ||
- | Integer to float conversion is untouched. Despite some people' | + | Integer to float conversion is untouched. Despite some people' |
+ | |||
+ | ===== Open Questions/ | ||
+ | |||
+ | Currently PHP throws an '' | ||
===== Proposed Voting Choices ===== | ===== Proposed Voting Choices ===== | ||
- | This is a "language change", arguably, so it requires a 2/3 majority. A straight Yes/No vote would be held. | + | This is a language change, so it requires a 2/3 majority. A straight Yes/No vote would be held. |
===== Patches and Tests ===== | ===== Patches and Tests ===== | ||
- | A work-in-progress patch is here: https:// | + | A pull request |
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 54: | 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=" | ||
+ | * Yes | ||
+ | * No | ||
+ | </ | ||
===== References ===== | ===== References ===== | ||
Line 64: | Line 98: | ||
===== Changelog ===== | ===== Changelog ===== | ||
+ | * v0.2.2 - Added examples | ||
+ | * v0.2.1 - Open Questions/ | ||
* 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