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

From Bruno Wolff III
Subject Re: Problem with datatype REAL using the = (EQUAL) operator
Date
Msg-id 20040215195554.GB570@wolff.to
Whole thread Raw
In response to Problem with datatype REAL using the = (EQUAL) operator  ("Javier Carlos" <javier@evaloportunidades.insp.mx>)
List pgsql-bugs
On Thu, Feb 12, 2004 at 12:46:27 -0600,
  Javier Carlos <javier@evaloportunidades.insp.mx> wrote:
> ============================================================================
> bd_temporal=> SELECT * FROM tbl_temp WHERE var < 0.20;
>  var
> ------
>   0.1
>  0.11
> (2 rows)
> bd_temporal=> SELECT * FROM tbl_temp WHERE var = 0.11;
>  var
> -----
> (0 rows)
> bd_temporal=> SELECT * FROM tbl_temp WHERE var = '0.11';
>  var
> ------
>  0.11
> (1 row)
>
>
> If you know how this problem might be fixed, list the solution below:

If you want exact fractional numbers you should be using numeric, not float.
The problems you are seeing has to do with single precision and double
precision versions of .11 not being equal.

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: Problem with datatype REAL using the = (EQUAL) operator
Next
From: Tom Lane
Date:
Subject: Re: copy problem