bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gawk] atan2(y,x) return value for y = 0 and x = -0


From: Hermann Peifer
Subject: Re: [bug-gawk] atan2(y,x) return value for y = 0 and x = -0
Date: Sun, 19 Jan 2014 10:10:21 +0100
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.2.0


Here a few more observations (as already posted to c.l.a)

# The input value -0.0 (rather than -0) makes a difference
$ awk -M 'BEGIN{ print atan2(-.0,-.0) }'
-3.14159

# Using the mpfr extension with input value -0
$ awk -l mpfr 'BEGIN{ print mpfr_atan2(0,-0) }'
0.0000000000000000E-1

# The trick with -0.0 doesn't help here
$ awk -l mpfr 'BEGIN{ print mpfr_atan2(0,-.0) }'
0.0000000000000000E-1

Hermann

On 2014-01-18 15:05, Janis Papanagnou wrote:
Complementary to Herman's view I think that -0 should be handled as +0;
so I'd qualify the first sample below as "Why is the result pi here?", and
the second sample as "Works as expected". Either way, I agree that this
looks like a bug.

Janis

 > Date: Sat, 18 Jan 2014 14:56:19 +0100
 > From: address@hidden
 > To: address@hidden
 > CC: address@hidden
 > Subject: atan2(y,x) return value for y = 0 and x = -0
 >
 > Hi,
 >
 > This might be a feature or a bug, but I thought it would be worth
reporting.
 >
 > # Works as expected
 > $ awk 'BEGIN{ pi = atan2(0,-0) ; printf "%.16f\n", pi }'
 > 3.1415926535897931
 >
 > # Why is the result 0 here ?
 > $ awk -M 'BEGIN{ pi = atan2(0,-0) ; printf "%.16f\n", pi }'
 > 0.0000000000000000
 >
 > # Works again as expected
 > $ awk -M 'BEGIN{ pi = atan2(0,-0.1) ; printf "%.16f\n", pi }'
 > 3.1415926535897931
 >
 > # I used gawk from git on Mac OS X, 10.9.1
 > $ awk -V | head -1
 > GNU Awk 4.1.60, API: 1.0 (GNU MPFR 3.1.1-p2, GNU MP 5.1.2)
 >
 > Hermann




reply via email to

[Prev in Thread] Current Thread [Next in Thread]