Re: strange sum behaviour

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-general(at)postgresql(dot)org
Cc: "Andrew Baerg" <andrew(dot)baerg(at)gmail(dot)com>
Subject: Re: strange sum behaviour
Date: 2006-08-29 17:57:55
Message-ID: 200608291957.56015.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> corp=# select sum(amount) from acc_trans where trans_id=19721 and
> chart_id=10019;
> sum
> ----------------------
> -1.4210854715202e-14

[expected to be 0]

Floating-point numbers are typically inaccurate like that, and if you
rely in equality comparisons, you're doing something wrong. You should
use numeric or fix your application to take these errors into account.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Enrique Alejandro Barrios 2006-08-29 17:59:42 SQL Tuning
Previous Message Karen Hill 2006-08-29 17:31:05 Re: strange sum behaviour