http://www.sqlite.org/lang_corefunc.html#round

Under the covers, when the second term to ROUND(X,y) is omitted, SQLite adds
0.5 and then truncates.    Because of floating point precision, some numbers
can not be represented exactly... causing the odd rounding you saw in your
examples.

I'll see what I can do to update the documentation and/or make the rounding
more consistent.

HTH.
-Shane


On Mon, Feb 15, 2010 at 12:03 PM, Phil Hibbs <sna...@gmail.com> wrote:

> Igor:
> > http://en.wikipedia.org/wiki/Rounding#Round_half_to_even
>
> So, are you saying round-half-to-even is the SQLite behaviour? I would
> have expected it to have used the "normal" mathematical convention of
> round-half-away-from-zero. The reason this is "normal" mathematical
> behaviour is that any decimal result is likely to be a truncation of
> the real result, e.g. "pi = 3.14195". The SQL standard leaves it up to
> the implementation:
>
> sec 4.4.1:
>         An approximation obtained by rounding of a numerical value N for
>         an <exact numeric type> T is a value V representable in T such
>         that the absolute value of the difference between N and the nu-
>         merical value of V is not greater than half the absolute value
>         of the difference between two successive numerical values repre-
>         sentable in T. If there are more than one such values V, then it is
>         implementation-defined which one is taken.
>
> So I guess "round half to even" is a reasonable interpretation, but
> I'd like to see this, and all implementation-defined behaviour,
> documented.
>
> Phil Hibbs.
> --
> Don't you just hate self-referential sigs?
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to