Re: No feedback for executing a mathematical expression

Jose Isaias Cabrera <[email protected]> Tue, 10 Mar 2020 12:42:01 +0000
Newsgroups gmane.comp.db.sqlite.general
Message-ID <VI1P195MB0654E958457647FFB6EDDF99DEFF0@VI1P195MB0654.EURP195.PROD.OUTLOOK.COM>
Keith Medcalf, on Tuesday, March 10, 2020 03:57 AM, wrote...
>
>
> On Tuesday, 10 March, 2020 01:22, Octopus ZHANG <[email protected]>
> 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
>
Thanks Keith for the lesson of the day. ;-)

josé
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users