Problems of precision with float8 type

Started by Gabriel Fernandezover 24 years ago1 messagesgeneral
Jump to latest
#1Gabriel Fernandez
gabi@unica.edu

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 :-)