react-number-format icon indicating copy to clipboard operation
react-number-format copied to clipboard

cutTrailingZeros prop added to the component

Open IGrobenskiTT opened this issue 3 years ago • 4 comments

added new prop => cutTrailingZeros (number) => if passed, then it will look for, and cut, ALL trailing zeros in the decimal part of the number, stopping at cutTrailingZeros decimal point.

So, in code, cutTrailingZeros is also used to determine the number of decimal places to leave intact when cutting trailing zeros. It's up to the developer, currently, to take care that the cutTrailingZeros prop's value isn't greater than decimalScale value (if such is used)

In case both decimalScale and cutTrailingZero props are used, if cutTrailingZero > decimalScale and fixedDecimal is used, it will display cutTrailingZero amount of decimals instead of decimalScale amount of decimals.

examples where this prop might be useful: e.g. 123,456.780 and cutTrailingZeros = 2 (because let's say that, while cutting trailing zeros, we still do want to keep at least 2 decimals and cut all trailing zeros after 2nd decimal place) then the result will be => 123,456.78 but if 123,456.780 and cutTrailingZeros = 3 (because let's say that, while cutting trailing zeros, we still do want to keep at least 3 decimals and cut all trailing zeros after 3rd decimal place) then the result will be => 123,456.780 .

Github issue that this PR solves: #611

Works in all browsers

IGrobenskiTT avatar Feb 11 '22 11:02 IGrobenskiTT

👍

Yusuf007R avatar Feb 26 '22 18:02 Yusuf007R

👍

can this be merged to DEV?

IGrobenskiTT avatar Feb 28 '22 16:02 IGrobenskiTT

i would really like to have this feature

Ostro avatar Apr 08 '22 08:04 Ostro

so useful !

abenhamdine avatar Oct 21 '22 10:10 abenhamdine