On Tue, Apr 17, 2012 at 5:12 AM, Paxdo Presse <pa...@mac.com> wrote: > > Hi, > > How point numbers are they stored in sqlite? > > In a field with REAL affinity: > > round(11.578767 / 2 , 4) is displayed "5.7894" in SQLite/Navicat :-), > but "5,7893999999999997" in the cursor of my development language > when I get it to sqlite. > > Internally, SQLite works with 5.7894 or 5,7893999999999997? >
Neither. SQLite uses double-precision IEEE floating point numbers. And the value 5.7894 is not representable as an IEEE float. The closest you can get is 5.78939999999999965751840136363171041011810302734375. SQLite only attempts to preserve the first 15 significant digits of a floating point value, so SQLite is likely to print that number as 5.7894. But if your development language tries to show 16 digits of precision (as apparently it does) then you might see the second value. Key point: Floating point numbers are approximations. This is an inherent property of IEEE floating point numbers, not a limitation of SQLite. If you need an exact answer, use integers. > > This is important because it can cause problems rounding. > ditto for the calculations on decimal currency. > > Greetings > olivier > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > -- D. Richard Hipp d...@sqlite.org _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users