Skip site navigation (1) Skip section navigation (2)

Minor bug in src/port/rint.c

From: Mark Cave-Ayland <mark(dot)cave-ayland(at)ilande(dot)co(dot)uk>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Minor bug in src/port/rint.c
Date: 2008-01-20 21:12:32
Message-ID: 1200863552.5556.23.camel@mca-desktop (view raw, whole thread or download thread mbox)
Lists: 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(at)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.



ILande - Open Source Consultancy

Attachment: test.c
Description: text/x-csrc (507 bytes)


pgsql-hackers by date

Next:From: Tom LaneDate: 2008-01-20 21:31:19
Subject: Re: Friendly help for psql
Previous:From: Greg SmithDate: 2008-01-20 20:55:54
Subject: Re: [HACKERS] bgwriter_lru_multiplier blurbs inconsistent

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group