python 3.x - qpython3 sqlite REAL float error -
this question has answer here:
- is floating point math broken? 20 answers
- unexpected floating-point representations in python 3 answers
i wrote on linux pc python3 in eric following code:
import sqlite3 conn = sqlite3.connect("dbug26.db") c=conn.cursor() c.execute("create table if not exists prices (price1 real,price2 real, price3 real, price4 real, price5 real)") c.execute("insert prices values (0.01, 0.01, 2.60, 0.01, 2.60)") conn.commit() c.execute("select * price") prices = c.fetchall() print (prices) c.close() conn.close() if run code in python3 in linux output is:
>>> [(2.6,), (1.0,), (2.6,), (1.01,)] but if run exactly same code in qpython3 on android output is:
>>> [(2.6000000000000001,), (1.0, ), ((2.6000000000000001,), (1.01, )] where decimal zeros , 1 in qpython3 come from? can prevent ?
if @ sqlite db in several db-browsers on linux,mac , android data appears correctly.
Comments
Post a Comment