BUG #4653: zero with negative sign returned on round(sin) function

Started by Marco Vieiraabout 17 years ago2 messagesbugs
Jump to latest
#1Marco Vieira
maovieira@gmail.com

The following bug has been logged online:

Bug reference: 4653
Logged by: Marco Vieira
Email address: maovieira@gmail.com
PostgreSQL version: 8.3.5
Operating system: x86_64-pc-linux-gnu (ubuntu 4.3.2-1ubuntu11 )
Description: zero with negative sign returned on round(sin) function
Details:

If I query select round(sin(2.0*pi()*0.51)) I get "-0" as return but zero is
unsigned.

but: select sin(2.0*pi()*0.51)
returns: -0.0627905195293133
and select round(-0.0627905195293133)
returns: 0 (no sign)

I used cast to work around it: select round(sin(2.0*pi()*0.51))::int

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Marco Vieira (#1)
Re: BUG #4653: zero with negative sign returned on round(sin) function

"Marco Vieira" <maovieira@gmail.com> writes:

If I query select round(sin(2.0*pi()*0.51)) I get "-0" as return but zero is
unsigned.

In IEEE-standard float arithmetic, that isn't true --- zero and minus
zero are distinguishable values. This is not a bug but just the way
your platform chooses to define the result of rounding a small
negative value.

(Or at least, if you are convinced it's a bug, take it up with the
glibc authors not us.)

regards, tom lane