[Tutor] trigonometry in python

Magnus Lycka magnus@thinkware.se
Fri Nov 1 07:44:01 2002


At 13:21 2002-11-01 +0100, Yigal Duppen wrote:
>The first is that there are two(*) ways to look at trig. You can count
>angles in degrees and you can count them in radians.

In other words, the wrong way and the right way! ;)

>0.49999999999999994
>
>Much better!
>
>However, we're still not getting 0.5
>This is where the second reason comes into play. As you might know, there is
>an infinite amount of real numbers. However, due to computer constraints
>there is only a limited amount of real numbers that can be represented on a
>computer. Therefore, Python often gives you an /approximation/ of the
>correct value.

Using the "print" statement usually fixes this. For more about
floating point problems, see the tutorial:
http://www.python.org/doc/current/tut/node14.html


-- 
Magnus Lycka, Thinkware AB
Alvans vag 99, SE-907 50 UMEA, SWEDEN
phone: int+46 70 582 80 65, fax: int+46 70 612 80 65
http://www.thinkware.se/  mailto:magnus@thinkware.se