Search Postgresql Archives

Re: Postgresql problem with update double precision

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

 



On Fri, 05 Aug 2011 07:20:01 -0400, Jerry Sievers wrote:
Condor <condor@xxxxxxxxxx> writes:

Hello ppl,
for few years I have problem when update double precision field. I
have table and few double precision columns, here is example:

sumall double precision,
sumin double precision,

My php script do:

$get = 2.40

and sql code is:

UPDATE table1 SET sumall = sumall + $get WHERE id = 1 AND rd =
CURRENT_DATE;


When I browse the table some times i see incorrect values like:

955.599999999998

it's should be 955.60 after these updates ... some days is fine, some
days the value is incorrect.

I have this problem from version 7 of postgresql, Im now use 9.0.3

Anyone know what can be the problem and why some times records is
fine, some times isnt ?

That floating point data types are inexact is a well known problem
with them and not Postgres specific.

Consider switching those fields to type NUMERIC.

HTH


--
Jerry Sievers
Postgres DBA/Development Consulting
e: postgres.consulting@xxxxxxxxxxx
p: 305.321.1144

Thank you, today I see all 3 rows is normal, but when I do select sum(sumall) I got 73.3000000001 as result.
Any way how I can convert field in numeric without to lose data ?

--
Regards,
Condor

--
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