math module broken?

Dan Bishop danb_83 at yahoo.com
Sat Jul 24 21:44:30 CEST 2004


Dan Sommers <me at privacy.net> wrote in message news:<m2hdrxr1iz.fsf at unique.fully.qualified.domain.name.yeah.right>...
> 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 ) ))
> [2 identical columns]

It's not suprising that they're identical: When 0 <= x < 360, then x % 360 == x.

However,

>>> x = 360000000000L  # a billion revolutions
>>> math.sin(math.radians(x))
-6.6394736764063769e-08
>>> math.sin(math.radians(x % 360))
0.0



More information about the Python-list mailing list