Re: Problem with datatype REAL using the = (EQUAL) operator

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Javier Carlos" <javier(at)evaloportunidades(dot)insp(dot)mx>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Problem with datatype REAL using the = (EQUAL) operator
Date: 2004-02-15 18:29:37
Message-ID: 9417.1076869777@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"Javier Carlos" <javier(at)evaloportunidades(dot)insp(dot)mx> writes:
> When I make a select and in the WHERE section I use the = (EQUAL)
> operator whith a column of real datatype the results of the query is 0
> rows even if there exist rows that match the condition.

This isn't a bug, it's a natural consequence of the limited precision of
the float4 datatype. The constant "0.11" defaults to type double
precision, and there is no float4 value that exactly equals the double
precision value of 0.11. Try casting the constant to float4 explicitly,
or putting quotes around it.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2004-02-15 18:31:32 Re: Default Timestamp 'Now' bug with 7.4 on Panther.
Previous Message Tom Lane 2004-02-15 17:33:29 Re: BUG? server closed the connection unexpectedly 7.4 on Windows (cygwin)