Round integer division

Поиск
Список
Период
Сортировка
От Lee Hachadoorian
Тема Round integer division
Дата
Msg-id 4C25334D.4040805@gmail.com
обсуждение исходный текст
Ответы Re: Round integer division
Re: Round integer division
Список pgsql-sql
Is it documented anywhere that floating-point numbers round
"scientifically", that is 0.5 rounds to the nearest even number? Compare:

SELECT round(2.5::real), round(2.5::numeric), round(3.5::real),
round(3.5::numeric);

generates

2 | 3 | 4 | 4

I stumbled across this when I was trying to use round(a::real/b::real)
to generate a rounded result to dividing integers, and noticed sometimes
0.5 was truncated and sometimes it was rounded up. Couldn't find
anything about this in the archives or the data type documentation. Is
there something obvious that I'm I missing?

Thanks,

-- 

Lee Hachadoorian
PhD Student, Geography
Program in Earth & Environmental Sciences
CUNY Graduate Center



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

Предыдущее
От: Frank Bax
Дата:
Сообщение: How do I remove selected words from text field?
Следующее
От: Scott Marlowe
Дата:
Сообщение: Re: Round integer division