@writetome51/get-float-padded-on-right-if-needed
v2.0.3
Published
Adds zeros to the end of a float if needed.
Downloads
5
Maintainers
Readme
getFloatPaddedOnRight_ifNeeded( num, numDigitsNeededAfterDecimal): string
Appends zeros to end of num
so it has required numDigitsNeededAfterDecimal
, if needed.
If num
already has or exceeds numDigitsNeededAfterDecimal
, the function
returns num
unchanged. It does not round or trim num
.
Examples
getFloatPaddedOnRight_ifNeeded(11, 1);
// --> '11.0'
getFloatPaddedOnRight_ifNeeded(11.1, 2);
// --> '11.10'
getFloatPaddedOnRight_ifNeeded(11.1556, 3);
// --> '11.1556'
getFloatPaddedOnRight_ifNeeded(11, 0);
// --> '11'
Installation
npm i @writetome51/get-float-padded-on-right-if-needed
Loading
import { getFloatPaddedOnRight_ifNeeded }
from '@writetome51/get-float-padded-on-right-if-needed';