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

Allow integer parsing #93

Open
BrOrlandi opened this issue May 8, 2019 · 1 comment
Open

Allow integer parsing #93

BrOrlandi opened this issue May 8, 2019 · 1 comment

Comments

@BrOrlandi
Copy link

When handling currency values in programming it's recommended to use integer values to avoid calculations and conversion mistakes due to the floating point problem.

So I want to discuss the possibility to have a prop called something like parseAsInteger so the value will be an integer, with the decimals multiplied by their precision.

So when the user input: 12,34 the value should be 1234, if the precision is 2.
If the precision is other like 3, the value 12,345 should be parsed as 12345.

Instead of having to multiply it by 100 by my self I would like to have the value parsed as integer like this.

For instance: 2.22 * 100 == 222 evaluates to false. When I multiply 2.22 by 100, it doesn't return an integer value due to the floating point problem.

I can make a PR but I want to have some feedback on this issue first.

@ericblade
Copy link

If you're still interested, I've just published @ericblade/react-currency-input^1.0.2 , which is pretty much identical in function to this repo, right now. there may be some slight behavior changes, and i removed the bits that were deprecated in this repo. I've placed a codepen at https://codepen.io/ericblade/pen/NWaLbGK

Whole thing is in typescript, and builds with the typescript compiler now.

I will be more than happy to continue work there (or if @jsillitoe returns, to hand it back off :) ) and accept pull reqs, and so on.

code repo is https://github.com/ericblade/react-currency-input

... I would 1000% be interested in flat out replacing the current handling with integer handling and issuing a major version upgrade.

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