mercredi 13 janvier 2016

SQLite - Arithmetic Error - floating point

I have a lot of tuples in my database, but the arithmetic operation returns an invalid result with these values:

select 2338.07 - (452.00 + 1886.07)

The results should be 0, but returns 4.54747350886464e-13.

This values are calculated by the query bellow:

select tb1.amount, sum(tb2.amount), tb1.amount- sum(tb2.amount)
from table tb1
inner join table tb2 ON tb2.id_super = tb1.id
group by tb1.amount
having tb1.amount <> sum(tb2.amount)

There are other values like these (integer vs float) and the operation described works fine.

I change the column type do NUMERIC and REAL, but the error remains the same.

What am I doing wrong?

Aucun commentaire:

Enregistrer un commentaire