[issue6198] test_float fails on Windows
James Abbatiello
report at bugs.python.org
Fri Jun 5 07:46:34 CEST 2009
New submission from James Abbatiello <abbeyj at gmail.com>:
test_float fails on Windows with:
======================================================================
FAIL: test_format_testfile (test.test_float.IEEEFormatTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Projects\python-trunk\lib\test\test_float.py", line 319, in
test_format_testfile
self.assertEqual(fmt % float(arg), rhs)
AssertionError: '3' != '2'
----------------------------------------------------------------------
The problematic line from formatfloat_testcases.txt is:
%.0f 2.5 -> 2
On some systems *printf() uses round-to-even. But the Windows CRT uses
round-half-away-from-zero. Consider the following C code:
printf("%+.1f -> %+.0f\n", -2.5, -2.5);
printf("%+.1f -> %+.0f\n", -1.5, -1.5);
printf("%+.1f -> %+.0f\n", +1.5, +1.5);
printf("%+.1f -> %+.0f\n", +2.5, +2.5);
On Linux this will produce:
-2.5 -> -2
-1.5 -> -2
+1.5 -> +2
+2.5 -> +2
And on Windows:
-2.5 -> -3
-1.5 -> -2
+1.5 -> +2
+2.5 -> +3
----------
components: Tests, Windows
messages: 88922
nosy: abbeyj
severity: normal
status: open
title: test_float fails on Windows
versions: Python 2.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6198>
_______________________________________
More information about the Python-bugs-list
mailing list