Re: some errors and/or bugs?
От | Tom Lane |
---|---|
Тема | Re: some errors and/or bugs? |
Дата | |
Msg-id | 2639.977187769@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | some errors and/or bugs? ("He Weiping(Laser Henry)" <laser@zhengmai.com.cn>) |
Ответы |
Re: some errors and/or bugs?
|
Список | pgsql-docs |
"He Weiping(Laser Henry)" <laser@zhengmai.com.cn> writes: > laser_zh=# select round(42.5); > round > ------- > 42 > (1 row) > > is it correct? I think result should be 43. It's correct, if the underlying float arithmetic is IEEE-compliant. Rounding for exact half-integral values is supposed to be "round to nearest even". So 42.5 goes to 42, but 43.5 goes to 44. I notice our NUMERIC rounding code does not do that ... perhaps it should. Also, the numeric round() function is just plain broken: regression=# select round(42.5::numeric); ERROR: Function 'numeric_round(numeric, int4)' does not exist Unable to identify a function that satisfies the given argument types You may need to add explicit typecasts regression=# select round(42.5::numeric,0); round ------- 43 (1 row) Looks like a silly oversight in the pg_proc entry for round(numeric). regards, tom lane
В списке pgsql-docs по дате отправления: