On Tue, Jul 5, 2016 at 3:59 PM, Ertan Küçükoğlu
<ertan.kucuko...@1nar.com.tr> wrote:
> Hi,
>
> I have following data to store:
>
> My currency values only has 2 decimal digits. (Sample: 1.23)
>
> My amount values goes around 5-6 decimal digits. (Sample: 1.123456)
>
> Will it be fine to store these values, and I will retrieve exactly what I
> save?
>
> Stored 1.123456 and retrieved 1.123456 exactly, no rounding or anything.
>

You can not store those _exact_ values in SQLite as floating-point.
You might need to represent that with something like 1.23456000000002.

But if reading/writing is the _only thing_ you're going to do with
them, that's fine. You can just round the value back to 6 decimal
places once you pull it out, and i'll be just as good. You can even
let SQL sort by them.

What you shouldn't do is let SQLite perform any significant arithmetic
on the value, because although your low precision offers quite a lot
of wiggle room, the error could in theory grow large enough to be a
problem if you're not careful.

-- 
Cory Nelson
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to