I am aware of how the numbers are stored but was overly optimistic that the 
shift could resolve this in all cases. It can't (and thanks for the 
correction). 
But my suggested alternative makes a significant difference in how often 
the problem arises:

>>> bad=[]
>>> for i in range(1,1000):
...  n = str(i)+'5'
...  if int(str(round(int(n)/10**len(n),len(n)-1))[-1])%2!=0:bad.append(i)  # 
e.g. round(0.1235, 3)
...
>>> len(bad)
546


>>> bad=[]
>>> for i in range(1,1000):
...  n = str(i)+'5'
...  if round(int(n)/10**len(n)*10**(len(n)-1))%2!=0:bad.append(i)  # e.g. 
round(0.1235*1000)
...
>>> len(bad)
8
>>> bad  # e.g. 0.545*100 != 54.5
[54, 57, 501, 503, 505, 507, 509, 511]

So the question is whether we want to do better and keep the SymPy 
> algorithm.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/b50c0504-ec96-4583-84b1-d5a3902277c2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to