James K. Lowden, on Sunday, May 26, 2019 04:51 PM, wrote...
>On Fri, 24 May 2019 13:10:49 +0000
>Jose Isaias Cabrera <jic...@outlook.com> wrote:
>
>> >Consider these two queries:
>> >
>> > SELECT round(3.255,2);
>> > SELECT round(3.2549999999999998,2);
>> >
>> >Do you expect them to give different answers?
>>
>> 3.26
>> 3.25
>
>sqlite> SELECT cast(100 * (0.005 + 3.2549999999999998) as
> ...> integer)/100.0;
>3.26
Ok, I think it happens even before the casting. This should be,
3.2599999999999998, and yet, it's 3.26.
11:23:07.55>sqlite3
SQLite version 3.28.0 2019-04-16 19:49:53
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> SELECT 0.005 + 3.2549999999999998;
3.26
I even tried casting it as real,
sqlite> SELECT cast(0.005 + 3.2549999999999998 as real);
3.26
sqlite> SELECT cast(3.2549999999999998 + 0.005 as real);
3.26
sqlite> SELECT cast((3.2549999999999998 + 0.005) as real);
3.26
sqlite>
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users