Re: The 85/0.0085 mistery ?

Поиск
Список
Период
Сортировка
От Hannu Krosing
Тема Re: The 85/0.0085 mistery ?
Дата
Msg-id 39DDE36E.E9FE04BC@tm.ee
обсуждение исходный текст
Ответ на RE: The 85/0.0085 mistery ?  ("Frederick W. Reimer" <fwr@ga.prestige.net>)
Список pgsql-hackers
Hannu Krosing wrote:
> 
> Tom Lane wrote:
> >
> > "Frederick W. Reimer" <fwr@ga.prestige.net> writes:
> > > In general, it's recommended you don't check for exact equivalence when
> > > doing calculations on real numbers and instead check for "almost exactness."
> >
> 
> perhaps "where trunc(85/0.0085) = 10000" works better.

ok I tested it and it does not work ;(

hannu=# select trunc(85.0::float4/0.0085::float4) = '10000';
ERROR:  Function 'trunc(float4)' does not exist       Unable to identify a function that satisfies the given argument
types      You may need to add explicit typecasts
 
hannu=# select trunc(float8(85.0::float4/0.0085::float4));trunc 
------- 9999
(1 row)

But this does work 

hannu=# select text(85.0::float4/0.0085::float4) = '10000';?column? 
----------t
(1 row)
As does this

hannu=# select round(float8(85.0::float4/0.0085::float4));round 
-------10000
(1 row)

--------------
Hannu


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

Предыдущее
От: Hannu Krosing
Дата:
Сообщение: Re: The 85/0.0085 mistery ?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: The 85/0.0085 mistery ?