Problems of precision with float8 type - Mailing list pgsql-general

From Gabriel Fernandez
Subject Problems of precision with float8 type
Date
Msg-id 3BE6C3B1.9C3A1FC6@unica.edu
Whole thread Raw
List 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 :-)



pgsql-general by date:

Previous
From: "Kenneth Skiles"
Date:
Subject: functions, shell script
Next
From: mbenzid@yahoo.de (Mounir Benzid)
Date:
Subject: How can I control whether to execute a query or not?