From: | Steve Atkins <steve(at)blighty(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: SELECT with REAL... |
Date: | 2006-02-06 18:32:57 |
Message-ID: | FF7463F8-5B6D-4BE6-9FF2-AD3C67FE1310@blighty.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Feb 6, 2006, at 10:21 AM, Philippe Ferreira wrote:
>
>> Comparing two floating point numbers for equality seldom works
>> the way you want it to.
>>
>> Without seeing the exact data you have it's hard to say for sure
>> (as there
>> may be some other issue with what you're doing) but I wouldn't expect
>> this to work with data from arbitrary sources.
>>
>> Try
>>
>> SELECT * FROM mytable WHERE myreal >= 10.49 AND myreal <= 10.51;
>>
>> and see what result that gives.
>>
> This way, it works...
Then the problem you're seeing isn't database-related, it's just due to
the standard problem of misuse of floating-point numbers. You'll
need to go back and look at the queries you're using and see what
comparisons you really want your application to be doing.
<http://www.lahey.com/float.htm> (or maybe
<http://docs.sun.com/source/806-3568/ncg_goldberg.html>
depending on your maths background) is well worth a read.
Cheers,
Steve
From | Date | Subject | |
---|---|---|---|
Next Message | Scott Marlowe | 2006-02-06 20:00:40 | Re: accidentally deleted rows |
Previous Message | Philippe Ferreira | 2006-02-06 18:32:53 | Re: SELECT with REAL... |