On 5/24/19, Jose Isaias Cabrera <[email protected]> wrote:
>
> FWIW, I went to sqlfiddle [1] and these are the answers for this SQL
> command:
>
> SELECT round(3.255,2), round(3.2549999999999998,2);
I also went to sqlfiddle and did a slightly more realistic scenario:
CREATE TABLE t1(a INT, b DOUBLE PRECISION);
INSERT INTO t1(a,b) VALUES(1,3.255);
INSERT INTO t1(a,b) VALUES(2,3.254999999999999893418589635);
SELECT a, b FROM t1;
In other words, I made the value actually pass through the database.
For MySQL I got:
1 3.26
2 3.26
For SQL Server I got:
1 3.25
2 3.25
The query does not work on PostgreSQL, because PG wisely prohibits
using the two-argument around() function on binary floating-point
values, perhaps to prevent discussions such as this one. In order to
get this to work on PG I had to modify the query as follows:
SELECT a, round(CAST(b AS NUMERIC),2) from t1
And the result is then:
1 3.26
2 3.26
--
D. Richard Hipp
[email protected]
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users