On 2/27/19, Jim Borden <jim.bor...@couchbase.com> wrote:
> Hello,
>
> I’ve been tracking down an odd problem where some of our results from an
> application defined SQLite function are coming back as infinity on some
> platforms (notably 32-bit Android, and all Windows).  I’ve narrowed it down
> to the following:
>
> Given the example input "1.7976931348623153e+308" encoded as UTF-8, the
> following lines of code have the following results (z is the const char*
> variable holding the text):
>
> double value = strtod(z, NULL); // value holds 1.7976931348623153E+308
> sqlite3AtoF(z, &value, sqlite3Strlen30(z), SQLITE_UTF8); // value now hold
> +Inf
>
> My theory as to why this varies by platform is because of the use of long
> double during this calculation, which can vary in size.  On the failing
> platforms they are the same size as regular double.  This results in a
> rounding error of the "scale" portion of the calculation (via sqlite3Pow10)
> which results in a false infinity.
>
> Would this be considered a bug, or is precision not guaranteed to the same
> level as strtod because of other factors?

This is a case of the precision not guaranteed due to other factors.

-- 
D. Richard Hipp
d...@sqlite.org
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to