Open yzhang123 opened 3 years ago
nice floating point converting problem, not really a bug and also not really not a bug
when will this be released?
when will this be released?
I don‘t no. Maybe clone this repository and fix this bug or use w2ni18n fork
I STRONGLY RECOMMEND SWITCHING TO PYTHON3.PYTHON2 IS DEPRECATED AND ONCE THIS GOES BIG IT WILL BE HARDER TO PORT. Use
import decimal
from decimal import Decimal as dcm
decimal.setcontext(decimal.Context(your_precision_here));
x = dcm("1.2349183205012354")#NOTE:STRING!!!
y = dcm(1.39689203452385093)#DOES NOT WORK;LITERAL IS ALREADY OFFSET
z = dcm(240213)#PERFECTLY OK
xx = dcm(13)/dcm(200)#OK TOO.ALL DECIMALS ARE FLOATING POINTS
yy = dcm(13.0/200.0)#BAD!OFFSET RESULT!
print x
##ps:also supports:
print x.sqrt()
print dcm.sqrt(x)
print x*x
print x/x
print x+x
print x-x
list of wrong conversions:
w2n.word_to_num('three point nine seven') ->3.9699999999999998 "two point seven eight" -> 2.7800000000000002 one point eight six -> 1.8599999999999999 two point seven two -> 2.7199999999999998 one point eight four -> 1.8399999999999999 two point two eight->2.2800000000000002 two point four seven->2.4699999999999998 one point five nine->1.5899999999999999