[New-bugs-announce] [issue30515] unittest: assertAlmostEqual rounding error

sam-s report at bugs.python.org
Tue May 30 13:26:28 EDT 2017


New submission from sam-s:

I get this `unittest` failure:

```
Traceback (most recent call last):
  File "zzz.py", line 348, in test_opposite
    self.assertAlmostEqual(a, b, places=2)
AssertionError: 1.1036640046288428 != 1.0986122886681098 within 2 places
```

This seems incorrect: 1.1036640046288428 rounded off to 2 places is 1.10 and so is 1.0986122886681098.

E.g., in Lisp:

```
> (round 1.1036640046288428d0 0.01)
110 ;
0.0036640292157588336d0
> (round 1.0986122886681098d0 0.01)
110 ;
-0.001387686744974238d0
```

----------
components: Library (Lib)
messages: 294772
nosy: sam-s
priority: normal
severity: normal
status: open
title: unittest: assertAlmostEqual rounding error
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30515>
_______________________________________


More information about the New-bugs-announce mailing list