SQLite不一致的行为

时间:2019-07-15 04:48:21

标签: python sqlite

我正在使用sqlite数据库进行一些计算。但是行为是不一致的。在我的本地计算机上,选择10.95-2.95表示8.0。

> sqlite3
> select 10.95 - 2.95
8.0

但是使用在线sqlite“ https://sqliteonline.com/”,选择10.95- 2.95,结果为7.999999999999999。这是奇怪的行为

这种奇怪的行为也使用python库“ https://docs.python.org/3.5/library/sqlite3.html

>>> from sqlite3 import connect
>>> con = connect(":memory:")
>>> c = con.cursor)
>>> t = c.execute("select 10.95 - 2.95")
>>> t.fetchone()
(7.999999999999999,)

0 个答案:

没有答案