Re: 'real' strange problem in 7.1.3

Поиск
Список
Период
Сортировка
От Knut Forkalsrud
Тема Re: 'real' strange problem in 7.1.3
Дата
Msg-id lzlmhfsdm9.fsf@darkstar.cj.com
обсуждение исходный текст
Ответ на 'real' strange problem in 7.1.3  (reina@nsi.edu (Tony Reina))
Список pgsql-hackers
reina@nsi.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.


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Chris Ryan
Дата:
Сообщение: Re: OT?: PGReplication project dead?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Quick question