Convert a float value to a percentage
function toPercentage(val) {
    var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
    var min = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
    var max = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;

    if (!isNumber(val) || isNumericalNaN(val)) {
        throw new TypeError('Value should be numeric');
    }

    if (!isNumber(min) || isNumericalNaN(min)) {
        throw new TypeError('Value should be numeric');
    }

    if (!isNumber(max) || isNumericalNaN(max)) {
        throw new TypeError('Value should be numeric');
    }

    return round((val - min) / (max - min) * 100, precision);
}