Skip to content

Trivially round a number and return fixed digit string 🐳

License

Notifications You must be signed in to change notification settings

hobbyquaker/fsuxx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fsuxx

npm version Bower Version Build Status License

Trivially round a number and return fixed digit string 🐳

Examples

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"

Documentation

fsuxx(num [, digits [, trailing [, comma]]]) ⇒ string

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

License

MIT (c) Sebastian Raff https://github.com/hobbyquaker

About

Trivially round a number and return fixed digit string 🐳

Resources

License

Stars

Watchers

Forks

Packages

No packages published