Problems of precision with float8 type

From: Gabriel Fernandez <gabi(at)unica(dot)edu>
To: PostgreSQL-general <pgsql-general(at)postgreSQL(dot)org>
Subject: Problems of precision with float8 type
Date: 2001-11-05 16:52:02
Message-ID: 3BE6C3B1.9C3A1FC6@unica.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I have some precision poblems using float8 type.

Look at this:

compta=> select import from apunts where assent = 4 ;

import
---------
9.38

AND THEN:

compta=> select import - round(import,2)::float8 as substraction from
apunts where assent = 4 ;

substraction
---------------------------
-1.77635683940025e-15

What is the cause of this ?

This is just the most simple example of the problem, but things get
worse when you use aggregate functions (sum , etc) and substraction ...

If I use the numeric type the problem just vanishes. But, Does the use
of numeric type instead of float8 results in a slower performance ?

Thanks,

Gabi :-)

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2001-11-05 16:53:00 Re: Function problems redux
Previous Message Josh Berkus 2001-11-05 16:49:09 Re: Porting Web application written in Oracle 8 PL/SQL