mercredi 20 mai 2015

SQLite returns incorrect arthimetic value

I'm working on a query that adds the following numbers and it's returning a puzzling result.

>SELECT ((36.7300 - 20.4300) - 16.3) AS Amount;
>-3.5527136788005e-15

I've tried everything I can think of like casting the values to different data types, but I'm still getting the same result.

When I separate out the steps it returns the right answer, but I can't get the two arthetic steps to work together for some reason.

>SELECT 36.7300 - 20.4300 AS Amount;
>16.3

>SELECT 16.3 - 16.3 AS Amount;
>0.0

Aucun commentaire:

Enregistrer un commentaire