In the C language, which sqlite is written in, performs math this way:
If mixing types the operands are converted to the most precise type and the
operation
evaluated.

=> SELECT 5 / 2;
is: integer operation integer
the most precise type is integer, so it's strictly integer math.
evaluated as integer / integer = integer result

=> SELECT 5 / 2.0;
is: integer operation float
the most precise type is float
evaluated as float / float = float result

It's performing as I expected based on my knowledge of C.


On 9/29/05, Ralf Junker <[EMAIL PROTECTED]> wrote:
>
> In risk of asking the obvious, I wonder if the following division should
> be considered correct:
>
> | Query | Result Value | Result Type | OK?
> -----------------------------------------------------------
> 1 | SELECT 5 / 2; | 2 | SQLITE_INTEGER | No?
> 2 | SELECT 5.0 / 2; | 2.5 | SQLITE_FLOAT | Yes
> 3 | SELECT 5 / 2.0; | 2.5 | SQLITE_FLOAT | Yes
> 4 | SELECT 5.0 / 2.0; | 2.5 | SQLITE_FLOAT | Yes
>
> The query in question is Query 1. Is the returned integer result correct
> or should it not better return the 2.5 float value instead?
>

Reply via email to