Minor bug in src/port/rint.c

Поиск
Список
Период
Сортировка
От Mark Cave-Ayland
Тема Minor bug in src/port/rint.c
Дата
Msg-id 1200863552.5556.23.camel@mca-desktop
обсуждение исходный текст
Ответы Re: Minor bug in src/port/rint.c  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Minor bug in src/port/rint.c  (Bruce Momjian <bruce@momjian.us>)
Список pgsql-hackers
Hi everyone,

I believe that there is a small bug in src/port/rint.c when the input
parameter has a fractional part of 0.5 which is demonstrated by the
attached program. It appears that the PG version of rint() rounds in the
wrong direction with respect to glibc.

mca@mca-desktop:~$ ./test
rint(-1.5): -2.000000
pg_rint(-1.5): -1.000000
rint(1.5): 2.000000
pg_rint(1.5): 1.000000

The fix is, of course, to add an equals into the if() comparisons on
lines 21 and 26, so that when the fractional part is 0.5, it rounds in
the opposite direction instead.

I'm sure that this will have practically zero effect on the code,
however it may be worth applying for correctness and consistency with
other platform implementations.


ATB,

Mark.

--
ILande - Open Source Consultancy
http://www.ilande.co.uk


Вложения

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

Предыдущее
От: Greg Smith
Дата:
Сообщение: Re: bgwriter_lru_multiplier blurbs inconsistent
Следующее
От: Teodor Sigaev
Дата:
Сообщение: Re: message string fixes