bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] sin() and cos() return wrong results


From: Andrew J. Schorr
Subject: Re: [bug-gawk] sin() and cos() return wrong results
Date: Thu, 18 Oct 2018 10:40:34 -0400
User-agent: Mutt/1.5.21 (2010-09-15)

Hi,

On Thu, Oct 18, 2018 at 04:53:11PM +0800, winn wrote:
> I found both sin() and cos() return wrong results in gawk-3.1.8 and 
> gawk-4.1.3.
> 
> 
> I compared the results with that in Excel, Windows calculator, and Python, 
> and confirmed this error.
> 
> 
> Please have a check.

Can you please provide some examples of calculations that you think are
incorrect? At first glance, it seems to work OK:

bash-4.2$ gawk 'BEGIN {pi = atan2(0, -1); print cos(0), sin(0), cos(pi/2), 
sin(pi/2)}'
1 0 6.12323e-17 1

This matches the results in Python 3.7:

bash-4.2$ python3 -c "from math import *; pi = atan2(0,-1); print(cos(0), 
sin(0), cos(pi/2), sin(pi/2))"
1.0 0.0 6.123233995736766e-17 1.0

Regards,
Andy



reply via email to

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