Skip site navigation (1) Skip section navigation (2)

Re: BUG #3467: Sum strange behaviour

From: Heikki Linnakangas <heikki(at)enterprisedb(dot)com>
To: Alex <AVShutko(at)mail(dot)khstu(dot)ru>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #3467: Sum strange behaviour
Date: 2007-07-18 09:50:10
Message-ID: 469DE252.6060405@enterprisedb.com (view raw or flat)
Thread:
Lists: pgsql-bugs
Alex wrote:
> I have a database with some float numbers (all of them are 2 digits
> presision). When I do select sum() I get this: 96.3100000000001
> ... 
> Is this bug or future ?

A feature. Floating point numbers can't generally represent a decimal
number exactly, so you get some rounding errors. Usually the errors are
small enough that they don't show up, but sometimes they do, like in
this example. I would recommend using NUMERIC instead of floats for
anything where the input data is in decimal format.

-- 
  Heikki Linnakangas
  EnterpriseDB   http://www.enterprisedb.com

In response to

pgsql-bugs by date

Next:From: SRIDHARANDate: 2007-07-18 11:34:51
Subject: BUG #3469: SELECT QRY
Previous:From: AlexDate: 2007-07-18 09:26:46
Subject: BUG #3467: Sum strange behaviour

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group