On Fri, Sep 19, 2014 at 11:46 AM, TimeOfDay.nl <[email protected]>
wrote:

> I am looking at my SQLite database in two ways:
>
> 1. from PHP, in my application,  thru 'select * from table' statements and
> the such
> 2. from Adminer, as a database management tool
>
> When I look at a field that is type Real, and has the value of -41.29 as
> the entered value, the results differ.
>
> - The PHP select gives me -41.29
> - Adminer gives me -41.289999999999999147
>
> Why this difference?  Does the php library do something to 'round' numbers
> to so-many decimals?
>


See http://www.sqlite.org/faq.html#q16

The think to remember is that IEEE floating point numbers are
approximations.  They are designed to solve real world physic problems.
And in the real world it is pysically impossible to tell -41.29 and
-41.289999999999999147 apart.  So you might as well think of them as the
same number.

A 64-bit IEEE floating point number variable cannot, in fact, contain
exactly -41.29.  The closest it can get is
-41.28999999999999914734871708787977695465087890625.  SQLite doesn't even
try to get that close - promising only that floating point value are
correct to 15 significant digits.

-- 
D. Richard Hipp
[email protected]
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to