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

Wrong decimal conversion #106

Closed
tmtisfree opened this issue Jan 2, 2021 · 3 comments
Closed

Wrong decimal conversion #106

tmtisfree opened this issue Jan 2, 2021 · 3 comments

Comments

@tmtisfree
Copy link

Using v1.9.2 or v1.12.0, numbers 64.74, 65.74, 66.74 etc. up to 81.74 are all given decimal words of 73 instead of 74, that is 'seventy-three' in English (or 'soixante treize' in French which I use) in whatever currency selected.

@ericamigo
Copy link

having the same issue with random numbers and .55, sometimes it gives me 'fifty-four' instead of 'fifty-five'

@kwn
Copy link
Owner

kwn commented Jul 20, 2021

Hi @tmtisfree and @eriqamiqo

Thank you for the issue report and sorry for a late reply. I'm worried that it's not a problem with number-to-words library, but rather with the way you store and multiply float values before you pass them to the currencyTransformer->toWords() method.

The toWords() method expects the value to be an integer. The issue you describe is a typical problem with floating point numbers representation. Could you please try to debug your code and ensure you pass the correct integer (with the correct type) to the toWords() method?

I opened a pull request to demonstrate that the numbers you highlighted are transcribed correctly: https://github.com/kwn/number-to-words/pull/116/files

Also please take a look at the above docs:

@tmtisfree
Copy link
Author

Hello,

You were right, just rounding the number (as per the first comment of your link) resolves the 'issue'.

Thank you!

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