This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Why is this expression == False?
Type: Stage:
Components: None Versions: Python 2.3
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: alexanro, doerwalter, mwh, tim.peters
Priority: normal Keywords:

Created on 2004-10-25 10:09 by alexanro, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg22846 - (view) Author: Alexander Rødseth (alexanro) Date: 2004-10-25 10:09
I am not sure if this is a bug or not, but I'm very curious 
of the reason for the following result: 
>>> from math import * 
>>> theta = pi 
This is supposed to be True, unless I've made some typo 
or made some other mistake. It's a version of Euler's 
msg22847 - (view) Author: Walter Dörwald (doerwalter) * (Python committer) Date: 2004-10-25 10:35
Logged In: YES 

This is due to rounding errors:
>>> from math import *
*>>> e**(1j*pi)
*>>> cos(pi)+1j*sin(pi)

Closing the bug report
msg22848 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2004-10-25 11:09
Logged In: YES 

Heh.  Walter, the two numbers you show are in fact equal.  Also, 
the expression is True for me.  I wonder what platform Alexander 
is on -- but not very much, attempting to verify equalities 
involving transcedental quantities using finite precision arithmetic 
is always going to be risky.
msg22849 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2004-10-27 03:35
Logged In: YES 

Try this one:

>>> 37.0 / 3 / 3 * 9 == 37.0

Worry about transcendentals after making peace with basic 
float arithmetic <wink>.
Date User Action Args
2022-04-11 14:56:07adminsetgithub: 41073
2004-10-25 10:09:23alexanrocreate