rfc:integer_semantics
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:integer_semantics [2014/08/19 22:05] – Not arguably ajf | rfc:integer_semantics [2017/09/22 13:28] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
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 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 " | ||
+ | |||
+ | <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, | ||
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 ===== | ||
Line 45: | Line 64: | ||
===== 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. | ||
===== Implementation ===== | ===== Implementation ===== | ||
- | After the project | + | |
- | - the version(s) it was merged to | + | Merged into master. It will be in PHP 7. |
- | - a link to the git commit(s) | + | |
- | | + | It is not yet in the manual. |
+ | |||
+ | ===== Vote ===== | ||
+ | |||
+ | As this is a language change, a 2/3 majority is required. | ||
+ | |||
+ | Voting started 2014-09-14 and ended on 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.1408485930.txt.gz · Last modified: 2017/09/22 13:28 (external edit)