New submission from Xinmeng Xia <xi...@smail.nju.edu.cn>:

In Python 2,the output is 1366. After converting by 2to3, the output is 
1197.1463275484991

There exists bug in the conversion of 2to3. The output should be consistent for 
original Python2 code and converted Python3 code. 

At line 10 of this python file. The code "integer /= 10" is not converted by 
2to3. Then I find there is no fixer for division in 2to3,which may lead to 
inaccuracy of output or even worse results.

A possible fix solution is for the division problem of 2to3 I can think is that 
for division expression such as a/b in Python2, we can add the following type 
check to check type of a,b as a fix for conversion of 2to3:

def DivOp(a, b):
       if (isinstance(a, int) and isinstance(b, int)):
                      return (a // b)
       else:
                      return (a / b)  
and modify a/b as Div(a,b) in converted Python3 file

----------
components: 2to3 (2.x to 3.x conversion tool)
files: euler016.py
messages: 348717
nosy: xxm
priority: normal
severity: normal
status: open
title: 2to3 Accuracy of calculation
type: behavior
versions: Python 3.7
Added file: https://bugs.python.org/file48515/euler016.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue37716>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to