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

Not properly converting number to text (100020 -> one thousand dollars, twenty cents) #553

Open
bwala-eightfold opened this issue Dec 26, 2023 · 1 comment

Comments

@bwala-eightfold
Copy link

Expected Behaviour

lang = en_US, Currency = USD
Function used -> num2words(100020, to='currency', currency='USD', lang='en_US')
100020 -> 'one hundred thousand dollars'

Actual Behaviour

lang = en_US, Currency = USD
Function used -> num2words(100020, to='currency', currency='USD', lang='en_US')
100020 -> 'one thousand dollars, twenty cents'

Mentioned above
image

Steps to reproduce

Steps are shown above

@bwala-eightfold bwala-eightfold changed the title Not properly converting number to text Not properly converting number to text (100020 -> one thousand dollars, twenty cents) Dec 26, 2023
@m-aciek
Copy link

m-aciek commented Jun 20, 2024

It looks like integers are being shifted left by two decimal places. It seems to be an undocumented feature. For floats (and decimals) there's no this behavior.

from num2words import num2words
num2words(100_020.56, to='currency')
Out[10]: 'one hundred thousand and twenty euro, fifty-six cents'
num2words(100_020.56, to='currency', currency='USD')
Out[11]: 'one hundred thousand and twenty dollars, fifty-six cents'
num2words(100_020., to='currency', currency='USD')
Out[12]: 'one hundred thousand and twenty dollars, zero cents'
num2words(100_020, to='currency', currency='USD')
Out[13]: 'one thousand dollars, twenty cents'
num2words(10_000_020, to='currency', currency='USD')
Out[14]: 'one hundred thousand dollars, twenty cents'
num2words(100_020, to='currency')
Out[15]: 'one thousand euro, twenty cents'
num2words(100_020., to='currency')
Out[16]: 'one hundred thousand and twenty euro, zero cents'from decimal import Decimal
num2words(Decimal(100_020), to='currency')
Out[18]: 'one hundred thousand and twenty euro, zero cents'

cc @szymon-borkowski

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

2 participants