math module broken?

Dan Sommers me at privacy.net
Sat Jul 24 09:13:40 EDT 2004


On 23 Jul 2004 23:00:18 -0700,
danb_83 at yahoo.com (Dan Bishop) wrote:

> danb_83 at yahoo.com (Dan Bishop) wrote in message news:<ad052e5c.0407231555.53f3ea11 at posting.google.com>...

>> def mysin(x):
>> return math.sin(math.radians(x))

> Even better:

> def mysin(x):
>    return math.sin(math.radians(x % 360))

Why?

>>> for x in range( 20 ):
     print '%.12f %.12f' % (math.sin( math.radians( x ) ), math.sin( math.radians( x % 360 ) ))

0.000000000000 0.000000000000
0.017452406437 0.017452406437
0.034899496703 0.034899496703
0.052335956243 0.052335956243
0.069756473744 0.069756473744
0.087155742748 0.087155742748
0.104528463268 0.104528463268
0.121869343405 0.121869343405
0.139173100960 0.139173100960
0.156434465040 0.156434465040
0.173648177667 0.173648177667
0.190808995377 0.190808995377
0.207911690818 0.207911690818
0.224951054344 0.224951054344
0.241921895600 0.241921895600
0.258819045103 0.258819045103
0.275637355817 0.275637355817
0.292371704723 0.292371704723
0.309016994375 0.309016994375
0.325568154457 0.325568154457

Regards,
Dan

-- 
Dan Sommers
<http://www.tombstonezero.net/dan/>
Never play leapfrog with a unicorn.



More information about the Python-list mailing list