Re: Divide a float4 by 1 - what is going on???????

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: Divide a float4 by 1 - what is going on???????
Дата
Msg-id 20050917004314.GA2817@winnie.fuhr.org
обсуждение исходный текст
Ответ на Divide a float4 by 1 - what is going on???????  (Daniel Schuchardt <daniel_schuchardt@web.de>)
Список pgsql-general
On Sat, Sep 17, 2005 at 02:12:45AM +0200, Daniel Schuchardt wrote:
> CIMSOFT=# SELECT n1/1 FROM test;
>     ?column?
> ------------------
> 2.45667695999146
> (1 row)
>
> Why I get so many digits by a division with one? Anybody should have
> learned that everything / 1 = everything ;-)

Looks like the division is being done in double precision (float8)
and you're seeing the effects of an inexact representation.

test=> SELECT 2.456677::real / 1;
     ?column?
------------------
 2.45667695999146
(1 row)

test=> SELECT 2.456677::real / 1::real;
 ?column?
----------
  2.45668
(1 row)

--
Michael Fuhr

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

Предыдущее
От: "Dann Corbit"
Дата:
Сообщение: Re: Divide a float4 by 1 - what is going on???????
Следующее
От: Bill Moseley
Дата:
Сообщение: Re: Setting WHERE on a VIEW with aggregate function.