Skip to content
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

Open
yzhang123 opened this issue Jan 22, 2021 · 4 comments
Open

w2n.word_to_num('three point nine seven') 3.9699999999999998 #54

yzhang123 opened this issue Jan 22, 2021 · 4 comments

Comments

@yzhang123
Copy link

yzhang123 commented Jan 22, 2021

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

bastie pushed a commit to bastie/w2ni18n that referenced this issue Jan 23, 2021
@bastie
Copy link

bastie commented Jan 23, 2021

nice floating point converting problem, not really a bug and also not really not a bug

@yzhang123
Copy link
Author

when will this be released?

@bastie
Copy link

bastie commented Jan 26, 2021

when will this be released?

I don‘t no. Maybe clone this repository and fix this bug or use w2ni18n fork

@00001H
Copy link

00001H commented Sep 13, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants