// Making value more human look
function humanizationNumber(value, decimalsLimit) {
var result = false;
var parts = value.toString().split('.');
var integer = parts[0];
var decimals = parts[1];
if (!(1 in parts)) {
// Value is nice looking integer
result = value
} else {
// Humanizing the decimals
var decimalsValue = decimals.split('');
var rationalLimit = decimalsLimit;
if (decimalsLimit > decimalsValue.length) {
// Do not round value under the limit
result = value
} else if ((Math.abs(integer) > 0) || (decimalsValue[0] > 0)) {
// Rounding to decimalsLimit
if ((Math.abs(integer) < 1) && (decimalsLimit < 1)) rationalLimit++;
result = parseFloat(parseFloat(integer + '.' + decimalsValue.join('')).toFixed(rationalLimit))
} else {
// Rounding to the first meaningful value
for (var count = 0; decimalsValue[count] < 1; count++) {
if (decimalsLimit <= count + 1) rationalLimit = count + 2;
result = parseFloat(parseFloat(integer + '.' + decimalsValue.slice(0, rationalLimit + 1).join('')).toFixed(rationalLimit))
}
}
}
return result;
}