From: | Knut Forkalsrud <kforkalsrud(at)cj(dot)com> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: 'real' strange problem in 7.1.3 |
Date: | 2001-11-09 23:55:58 |
Message-ID: | lzlmhfsdm9.fsf@darkstar.cj.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
reina(at)nsi(dot)edu (Tony Reina) writes:
> db02=# select distinct arm from ellipse where exag_ratio = 1.0;
You never want to use the = test on floating point numbers. Two
apparently equal numbers may differ in the least significant digit.
The behavior will be close to random.
When you convert the floating point to a string and round off to a
specific number of digits, you can use string compare to get more
predictable results.
Another possibility is to do something like
where abs(exag_ratio - 1.0) > 0.000001
(I'm not sure about the SQL function for absolute value, but you get
the idea).
-Knut
--
The early worm gets the bird.
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2001-11-10 00:16:54 | Re: Bug?? -- Alter table drop constraint doesn't seem to work on a primary key constraint in 7.2beta2 |
Previous Message | Tom Lane | 2001-11-09 23:55:54 | Re: best method of reloading pg_hba.conf |