I'm trying use Y.Number.format for formatting my numbers. I need to use 6 decimalPlaces but if there is one and and don't use right zero-padding if the source number has no this count of decimals.
Basically I need the following:
YUI().use("datatype-number", function(Y) {
console.log(Y.Number.format(1234.567, {
thousandsSeparator: ".",
decimalPlaces: 2
}
));
//Result is: 1234.57
and
YUI().use("datatype-number", function(Y) {
console.log(Y.Number.format(1234.567, {
thousandsSeparator: ".",
decimalPlaces: 6
}
));
//Result is 1234.567
How could I achieve the results above?
Maybe this will work (num%1) is num modulo 1. Divide num by 1 and see what's left over.
Example of how you can use it: