On Thu, 4 Apr 2019 17:30:29 +0200 Lifepillar <lifepil...@icloud.com> wrote:
> On 4 Apr 2019, at 17:15, James K. Lowden <jklow...@schemamania.org> > wrote: > > On Wed, 3 Apr 2019 14:30:52 +0200 > > Lifepillar <lifepil...@icloud.com> wrote: > >> SQLite3 Decimal is an extension implementing exact decimal > >> arithmetic for SQLite3. > > > > What does divide-by-zero yield? > > By default: > > sqlite> select decDiv(1,0); > Error: Division by zero > > You have the option to ignore the error, though, in which case you > get +Inf: > > sqlite> delete from decTraps where flag = 'Division by zero'; > sqlite> select decStr(decDiv(1,0)); > Infinity > > decTraps is a virtual table containing a list of flags which, when > set by some function, raise an error. The flags are from IEEE 754. Nice. Division by zero can be a problem in other DBMSs because, if it occurs, the query aborts, and you then have to search for the cases and decide what to do. By flagging and marking them, you make that task easier. Especially when the query runs for a long time. > NULLs are avoided where other results make sense. For instance: > > sqlite> create table T (n blob); > sqlite> select decStr(decSum(n)) from T; -- Sum of an empty set of > sqlite> values > 0 > sqlite> select decStr(decAvg(n)) from T; -- Avg. of empty set of > sqlite> values > NaN Here, as you may know, you're in close touch with SQL's ambivalent ambiguity with NULL. Should the sum of nulls be 0? Should the count be 0? Just one example of how SQL is a fossil from the 1980s. --jkl _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users