Yes, I fear users are attempting simplistic banking apps with floating
point rounds. :(
May explain where millions of my pennies went in my last android stock sale!

On Fri, May 24, 2019 at 1:55 PM Warren Young <[email protected]> wrote:

> On May 24, 2019, at 7:10 AM, Jose Isaias Cabrera <[email protected]>
> wrote:
> >
> > Dr. Richard Hipp, on Friday, May 24, 2019 08:44 AM, wrote...
> >>> Dr. Hipp, how many more scenarios, where round gives the wrong answer,
> >>> exist?  Thanks.
> >>
> >> Consider these two queries:
> >>
> >>  SELECT round(3.255,2);
> >>  SELECT round(3.2549999999999998,2);
> >>
> >> Do you expect them to give different answers?
> >
> > 3.26
> > 3.25
>
> Go read this: https://www.floating-point-gui.de/
>
> Then install this extension:
>
>     https://chiselapp.com/user/lifepillar/repository/sqlite3decimal/index
>
> Having done both, you’ll know why SQLite does what it does, and will have
> a solution for the problem where it matters.
>
> And it doesn’t always matter!  Anything dealing in real-world
> measurements, for example, generally doesn’t need more than 9 decimal
> digits of precision, depending on the measuring instrument, which is more
> than covered by an IEEE-754 double.  Measurement instruments are not
> absolutely precise: they have inherent inaccuracies, and electronic
> instruments have drift and other characteristics that can prevent them from
> giving the same answer given the same task.
>
> Since the measurement itself cannot be more precise than an IEEE-754
> double, any “error” in an answer computed from it is down in the noise
> floor of the measurement.  That is to say, two measurements taken
> back-to-back might give the same or greater error.
>
> This is no accident.  IEEE-754 was designed by people working in the
> physical sciences, and they knew all of this when they designed it.  It is
> what it was designed *for*.
>
> What IEEE-754 was *not* designed for was discrete math, such as monetary
> matters on scales smaller than a national economy.
> _______________________________________________
> sqlite-users mailing list
> [email protected]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to