Skip site navigation (1) Skip section navigation (2)

Re: Bug #627:

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: rao(dot)harish(at)acm(dot)org, pgsql-bugs(at)postgresql(dot)org
Subject: Re: Bug #627:
Date: 2002-03-29 14:52:44
Message-ID: 890.1017413564@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugs
pgsql-bugs(at)postgresql(dot)org writes:
> create table t1 (f1 real);
> insert into t1 values(1.01);
> select * from t1 where f1 > 1.01;

regression=# create table t1 (f1 real);
CREATE
regression=# insert into t1 values(1.01);
INSERT 139787 1
regression=# select * from t1 where f1 > 1.01;
 f1
----
(0 rows)

And your point was?

BTW, if you were going to complain that on your platform the SELECT
returns the row, don't bother.  Float comparisons are inherently
inaccurate.

You might, however, find that the behavior is less surprising if you do
the comparison against a float4 (== real) rather than float8 constant:

select * from t1 where f1 > '1.01'::real;

The query as you wrote it will convert the original 1.01 to float4
for storage and then to float8 for comparison against the second 1.01
(which never becomes float4), so a little bit of roundoff error is
likely to creep in.

			regards, tom lane

In response to

  • Bug #627: at 2002-03-29 07:27:55 from pgsql-bugs

pgsql-bugs by date

Next:From: Ryan GrangeDate: 2002-03-31 17:05:57
Subject: PGAccess and apostrophes...
Previous:From: Stephan SzaboDate: 2002-03-29 13:59:02
Subject: Re: Bug #627:

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group