rfc:change_the_edge_case_of_round
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
rfc:change_the_edge_case_of_round [2023/11/08 16:03] – saki | rfc:change_the_edge_case_of_round [2023/11/08 16:36] – saki | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== PHP RFC: Change the edge case of round() ====== | ====== PHP RFC: Change the edge case of round() ====== | ||
- | * Version: 0.4.0 | + | * Version: 0.4.1 |
* Date: 2023-10-23 | * Date: 2023-10-23 | ||
* Author: Saki Takamachi, saki@sakiot.com | * Author: Saki Takamachi, saki@sakiot.com | ||
Line 94: | Line 94: | ||
// 1.55 | // 1.55 | ||
</ | </ | ||
+ | |||
+ | Ruby behaves the same as current PHP, and Python behaves the same as this RFC aims to do. | ||
==== Reference: Databases ==== | ==== Reference: Databases ==== | ||
- | In most databases, | + | When it comes to databases, |
MySQL: | MySQL: | ||
< | < | ||
- | mysql> SELECT | + | mysql> SELECT |
- | +-----------------+ | + | +---------------------------------+ |
- | | ROUND(0.285, | + | | 1555E-3 = 15549999999999999E-16 |
- | +-----------------+ | + | +---------------------------------+ |
- | | | + | | 1 | |
- | +-----------------+ | + | +---------------------------------+ |
- | mysql> SELECT ROUND(0.28499999999999998, 2); | + | mysql> SELECT ROUND(1555E-3, 2); |
- | +-------------------------------+ | + | +-------------------+ |
- | | ROUND(0.28499999999999998, 2) | | + | | ROUND(1555E-3, 2) | |
- | +-------------------------------+ | + | +-------------------+ |
- | | 0.28 | | + | | 1.56 | |
- | +-------------------------------+ | + | +-------------------+ |
- | </ | + | |
- | PostgreSQL: | + | mysql> SELECT ROUND(15549999999999999E-16, 2); |
- | <code> | + | +---------------------------------+ |
- | postgres=# | + | | ROUND(15549999999999999E-16, 2) | |
- | round | + | +---------------------------------+ |
- | ------- | + | | 1.56 | |
- | | + | +---------------------------------+ |
- | + | ||
- | postgres=# SELECT | + | |
- | | + | |
- | ------- | + | |
- | 0.28 | + | |
</ | </ | ||
SQLite3: | SQLite3: | ||
< | < | ||
- | sqlite> SELECT ROUND(0.285, 2); | + | sqlite> SELECT 1555E-3 = 15549999999999999E-16; |
- | 0.29 | + | 1 |
- | + | sqlite> SELECT ROUND(1555E-3, 2); | |
- | sqlite> SELECT ROUND(0.28499999999999998, 2); | + | 1.56 |
- | 0.29 | + | sqlite> SELECT ROUND(15549999999999999E-16, 2); |
+ | 1.56 | ||
</ | </ | ||
Firebird: | Firebird: | ||
< | < | ||
- | SQL> SELECT | + | SQL> SELECT |
- | ROUND | + | |
- | ===================== | + | ======================= |
- | 0.290 | + | 1.554999999999999937828 |
- | SQL> SELECT ROUND(0.28499999999999998, 2) FROM RDB$DATABASE; | + | SQL> SELECT ROUND(1555E-3, 2) FROM RDB$DATABASE; |
- | | + | |
- | ===================== | + | ======================= |
- | 0.28000000000000000 | + | 1.560000000000000053291 |
</ | </ | ||
SqlServer: | SqlServer: | ||
< | < | ||
- | 1> SELECT | + | 1> SELECT |
2> go | 2> go | ||
- | + | | |
- | ----- | + | ------------------------ |
- | .290 | + | 1.5549999999999999 |
- | 1> SELECT ROUND(0.28499999999999998, 2); | + | 1> SELECT ROUND(1555E-3, 2); |
2> go | 2> go | ||
- | + | | |
- | ------------------- | + | ------------------------ |
- | .28000000000000000 | + | 1.55 |
</ | </ | ||
+ | |||
+ | MySQL, SQLite, Firebird are similar to current PHP. SqlServer is similar to what this RFC is aiming for. | ||
+ | |||
+ | (PostgreSQL requires some effort to round with double precision, and we are currently working on it. I will add it as soon as I can.) | ||
===== Proposal ===== | ===== Proposal ===== |
rfc/change_the_edge_case_of_round.txt · Last modified: 2023/12/08 00:37 by saki