-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
w2n.word_to_num('three point nine seven') 3.9699999999999998 #54
Comments
bastie
pushed a commit
to bastie/w2ni18n
that referenced
this issue
Jan 23, 2021
nice floating point converting problem, not really a bug and also not really not a bug |
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. 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
The text was updated successfully, but these errors were encountered: