Trivially round a number and return fixed digit string 🐳
var fsuxx = require("fsuxx");
console.log(fsuxx(0.199000000000000004)); // "0.199"
console.log(fsuxx(0.199000000000000004, 2)); // "0.2"
console.log(fsuxx(0.199000000000000004, 2, true)); // "0.20"
console.log(fsuxx(0.199000000000000004, 2, true, true)); // "0,20"
Takes a number and returns a rounded fixed digit string. Returns an empty string if first parameter is (-)Infinity or parseFloat results in NaN. If parameter trailing is set to true trailing zeros will be kept.
Param | Type | Default | Description |
---|---|---|---|
num | number |
the number | |
[digits] | number |
3 |
digit count |
[trailing] | boolean |
false |
keep trailing zeros |
[comma] | boolean |
false |
use comma as decimal separator |
MIT (c) Sebastian Raff https://github.com/hobbyquaker