Search Postgresql Archives

Re: Floating point error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>>>>> "TD" == Tom Duffey <tduffey@xxxxxxxxxxxxxx> writes:

TD> Riddle me this. I have a database column of type "real" that gets
TD> mapped to a Java field of type double via JDBC. ...

TD> - Selecting values from both test and production DBs using psql
TD>   shows "10.3885" as the value

TD> - The Java app on production shows "10.3884573" while the test app
TD>   shows "10.3885"

I suspect the issue is that psql(1) and whatever java method you use to
convert the floats to text choose different rounding.

By default, it seems that psql(1) uses something like printf("%.4f",...)
whereas your java app calls a routing which works more like "%.7f".

(The wire format for floats is the same as they are stored, not a text
representation thereof.)

-JimC
-- 
James Cloos <cloos@xxxxxxxxxxx>         OpenPGP: 1024D/ED7DAEA6


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux