Re: BUG #1577: round(dp) function does not round to nearest integer properly
От | Russell Smith |
---|---|
Тема | Re: BUG #1577: round(dp) function does not round to nearest integer properly |
Дата | |
Msg-id | 200504110845.14546.russell@pws.com.au обсуждение исходный текст |
Ответ на | Re: BUG #1577: round(dp) function does not round to nearest integer properly (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: BUG #1577: round(dp) function does not round to nearest integer properly
|
Список | pgsql-bugs |
On Mon, 11 Apr 2005 05:57 am, Tom Lane wrote: > "Roman Schayuk" <rschayuk@rogers.com> writes: > > gap=> select round(42.5); > > round > > ------- > > 42 > > (1 row) > > Result has to be 43 > > No, the above is perfectly correct and in fact required by the IEEE > standard for floating-point arithmetic (because round-to-nearest-even > is the default rounding mode). > That is rounding of unrepresentable numbers, is it not? at least http://www.ee.ucla.edu/~vandenbe/103/flpt.pdf suggests that to me as I couldn't find the IEEE spec about this. I'm sure somebody has it at hand, but I don't. Either way 8.0.1 round differently; test=# select version(); version -------------------------------------------------------------------------------------------------------------------------- PostgreSQL 8.0.1 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.3.2 20031218 (Gentoo Linux 3.3.2-r5, propolice-3.3-7) (1 row) test=# select round(42.5); round ------- 43 (1 row) test=# select round(42.5,0); round ------- 43 (1 row) > If anything needs to be changed here, it's the behavior of round(numeric). > So I would say that the round behaviour has changed as Tom has suggested, but which is correct? 7.2, or 8.0? Regards Russell Smith
В списке pgsql-bugs по дате отправления: