A very helpful and clear explanation to many of us not familiar with SQLite’s math idiosyncracies, or simply needing a refresher. Many thanks Keith.
> On Mar 10, 2020, at 8:57 AM, Keith Medcalf <kmedc...@dessus.com> wrote: > > > On Tuesday, 10 March, 2020 01:22, Octopus ZHANG <zhangysh1...@gmail.com> > wrote: > >> I try to run a simple math expression, but SQLite gives no feedback : > >> sqlite> select 99-(55/(30/57)); > >> Should I expect it to return nothing? > > It is returning something. It is returning NULL. > > sqlite> .nullvalue <NULL> > sqlite> select 99-(55/(30/57)); > <NULL> > sqlite> > > 99 - (55 / (30 / 57)) > > 30 / 57 -> 0 > > 55 / 0 -> NULL > > 99 - NULL -> NULL > > If you want the result of 30/57 to be a floating point number (ie, not zero), > you need to have one of those numbers be floating point, after which each > successive operation will be carried out in floating point rather than > integer arithmetic. > > 30. / 57 == 30 / 57. == 30. / 57. -> 0.526315789473684 > > 55 / 0.526315789473684 -> 104.5 > > 99 - 104.5 -> -5.5 > _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users