rfc:integer_semantics
Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
rfc:integer_semantics [2014/08/19 19:48] ajf plural |
rfc:integer_semantics [2014/09/15 16:32] ajf |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== PHP RFC: Integer Semantics ====== | ====== PHP RFC: Integer Semantics ====== | ||
- | * Version: 0.2 | + | * Version: 0.2.3 |
* 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 25: | Line 44: | ||
" | " | ||
- | On Intel CPUs, a bitwise shift by a number of bits that is greater than the bit width of an integer (e.g. ''>> | + | On Intel CPUs, a bitwise shift by a number of bits that is greater than the bit width of an integer (e.g. ''>> |
Making NaN and Infinity always become zero when casted to integer means more cross-platform consistency, | Making NaN and Infinity always become zero when casted to integer means more cross-platform consistency, | ||
- | The changes in this RFC are all backported from my [[rfc: | + | The changes in this RFC are all backported from my [[rfc: |
===== Proposed PHP Version(s) ===== | ===== Proposed PHP Version(s) ===== | ||
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' |
===== 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 |
- | It is nearly finished, | + | The patch is working |
===== Implementation ===== | ===== Implementation ===== | ||
Line 54: | Line 73: | ||
- 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 94: | ||
===== Changelog ===== | ===== Changelog ===== | ||
+ | * v0.2.3 - Removed "Open Questions/ | ||
+ | * 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 (external edit)