Re: Should casting to integer produce same result as trunc()

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Should casting to integer produce same result as trunc()
Дата
Msg-id 25886.1318340505@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Should casting to integer produce same result as trunc()  (Alban Hertroys <haramrae@gmail.com>)
Ответы Re: Should casting to integer produce same result as trunc()
Список pgsql-general
Alban Hertroys <haramrae@gmail.com> writes:
> On 11 Oct 2011, at 2:55, Harvey, Allan AC wrote:
>> My simple understanding of trunc() and casting to an integer says that
>> there is a bug here.

> Which the type-cast should round to 4380103 and 4380104 respectively.
> It doesn't:

That's because a cast from float to int rounds, it doesn't truncate.

regression=# select (4.7::float8)::int;
 int4
------
    5
(1 row)


            regards, tom lane

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

Предыдущее
От: Eric Radman
Дата:
Сообщение: Global Variables?
Следующее
От: Alban Hertroys
Дата:
Сообщение: Re: Global Variables?