Thread: Problems of precision with float8 type

Problems of precision with float8 type

From
Gabriel Fernandez
Date:
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 :-)