rfc:precise_float_value
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:precise_float_value [2016/05/30 16:27] – Update RFC and add me as an co-author bukka | rfc:precise_float_value [2016/06/19 18:41] – Close vote bukka | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | |||
====== PHP RFC: More precise float value handling ====== | ====== PHP RFC: More precise float value handling ====== | ||
- | * Version: 1.0 | + | * Version: 1.1 |
* Date: 2015-07-30 | * Date: 2015-07-30 | ||
* Author: Yasuo Ohgaki < | * Author: Yasuo Ohgaki < | ||
- | * Status: | + | * Status: |
* First Published at: http:// | * First Published at: http:// | ||
Line 11: | Line 10: | ||
This RFC is based on the discussion about displaying float values in json_encode and proposes more precise float value handling overall. | This RFC is based on the discussion about displaying float values in json_encode and proposes more precise float value handling overall. | ||
- | JSON is used to exchange data between systems. Although [[https:// | + | JSON is used to exchange data between systems. Although [[https:// |
- | Currently, json_encode() uses EG(precision) which is set to 14. That means that 14 digits | + | Currently json_encode() uses EG(precision) which is set to 14. That means that 14 digits |
<code php> | <code php> | ||
Line 63: | Line 62: | ||
===== Proposal ===== | ===== Proposal ===== | ||
- | This RFC proposes to introduce EG(precision)=-1 and PG(serialize_precision)=-1 that uses zend_dtoa()' | + | This RFC proposes to introduce |
- | Since JSON is used extensively | + | The RFC also proposes changing ini for JSON precision |
Followings are sample codes and outputs of the proposed patch. | Followings are sample codes and outputs of the proposed patch. | ||
Line 76: | Line 75: | ||
ini_set(' | ini_set(' | ||
ini_set(' | ini_set(' | ||
- | ini_set(' | ||
var_dump($v); | var_dump($v); | ||
Line 99: | Line 97: | ||
ini_set(' | ini_set(' | ||
ini_set(' | ini_set(' | ||
- | ini_set(' | ||
var_dump($v); | var_dump($v); | ||
echo var_export($v, | echo var_export($v, | ||
+ | ini_set(' | ||
echo json_encode($v), | echo json_encode($v), | ||
+ | ini_set(' | ||
echo $v, PHP_EOL; | echo $v, PHP_EOL; | ||
?> | ?> | ||
Line 121: | Line 120: | ||
Setting mode 0 as default can mean that the rounding will be more precise which also means that the rounding might be different in var_export()/ | Setting mode 0 as default can mean that the rounding will be more precise which also means that the rounding might be different in var_export()/ | ||
- | The BC break could happen only if someone would rely on exact output but that shouldn' | + | The BC break could happen only if someone would rely on exact output but that shouldn' |
None when old INI value is used. | None when old INI value is used. | ||
Line 137: | Line 136: | ||
* 0 mode (EG(precision)= -1) float outputs values rounded to nearest. | * 0 mode (EG(precision)= -1) float outputs values rounded to nearest. | ||
- | Standard module | + | Standard module |
- | * serialize(), | + | * serialize(), |
- | + | ||
- | JSON | + | |
- | * json_encode() - Use ini selected from the vote result and 0 mode by default. | + | |
==== To Opcache ==== | ==== To Opcache ==== | ||
Line 160: | Line 155: | ||
serialize_precision | serialize_precision | ||
- | * hardcoded default values : -1 | ||
- | * php.ini-development values : -1 | ||
- | * php.ini-production values : -1 | ||
- | |||
- | json.precision (if accepted) | ||
* hardcoded default values : -1 | * hardcoded default values : -1 | ||
* php.ini-development values : -1 | * php.ini-development values : -1 | ||
Line 188: | Line 178: | ||
- | ===== Proposed | + | ===== Voting ===== |
- | Requires a 50%+1 majority | + | Requires a 2/3 majority for the first vote (mode 0 to become default for serialize precision) and 50%+1 majority |
- | There will be two votings | + | The both votes are straight Yes/No votes. |
- | * whether to introduce | + | <doodle title=" |
- | * what precision ini should | + | |
+ | * No | ||
+ | </ | ||
+ | |||
+ | <doodle title=" | ||
+ | * Yes | ||
+ | * No | ||
+ | </ | ||
+ | |||
+ | The votes started on 2016-06-12 at 19:00 UTC and ended on 2016-06-19 at 19:00 UTC. | ||
===== Patches and Tests ===== | ===== Patches and Tests ===== | ||
+ | |||
+ | The initial PR can be found here: | ||
* https:// | * https:// | ||
+ | |||
+ | Note that the PR is currently outdated but it will be updated if the RFC is accepted. | ||
===== Implementation ===== | ===== Implementation ===== | ||
Line 214: | Line 217: | ||
===== Rejected Features ===== | ===== Rejected Features ===== | ||
- | Keep this updated with features that were discussed on the mail lists. | + | |
+ | None | ||
rfc/precise_float_value.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1