New submission from James Abbatiello <abb...@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 <rep...@bugs.python.org> <http://bugs.python.org/issue6198> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com