Re: Problem with datatype REAL using the = (EQUAL) operator - Mailing list pgsql-bugs

From Tom Lane
Subject Re: Problem with datatype REAL using the = (EQUAL) operator
Date
Msg-id 9417.1076869777@sss.pgh.pa.us
Whole thread Raw
In response to Problem with datatype REAL using the = (EQUAL) operator  ("Javier Carlos" <javier@evaloportunidades.insp.mx>)
List pgsql-bugs
"Javier Carlos" <javier@evaloportunidades.insp.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

pgsql-bugs by date:

Previous
From: Harry Hochheiser
Date:
Subject: Default Timestamp 'Now' bug with 7.4 on Panther.
Next
From: Bruno Wolff III
Date:
Subject: Re: Problem with datatype REAL using the = (EQUAL) operator