Re: float4 problem - Mailing list pgsql-hackers

From Doug McNaught
Subject Re: float4 problem
Date
Msg-id m3d6p0jkou.fsf@varsoon.wireboard.com
Whole thread Raw
In response to float4 problem  (Oleg Bartunov <oleg@sai.msu.su>)
Responses Re: float4 problem  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Oleg Bartunov <oleg@sai.msu.su> writes:

> May be I miss something, but seems there is a problem with float4
> in 7.2.3 and 7.3RC1 (6.53 works fine):
> 
> test=# create table t ( a float4);
> CREATE TABLE
> test=# insert into t values (0.1);
> INSERT 32789 1
> test=# select * from t where a=0.1;
>  a
> ---
> (0 rows)


I'm guessing this is because 0.1 is not directly representable as a
binary floating point number, and literal floating constants are
float8 not float4, and 0.1::float4 != 0.1::float8.  Same problem that
causes queries on int2 fields not to use an index unless you cast the
constants in the query...

-Doug


pgsql-hackers by date:

Previous
From: Oleg Bartunov
Date:
Subject: float4 problem
Next
From: "Ken Hirsch"
Date:
Subject: Re: Geometry test on NetBSD (was Re: RC1?)