
// extensions to standard Math javascript object

// Quadratic Formula
Math.quadratic = function (a, b, c, sign) {
    var plusminus = sign ? 1 : -1;
    return ( -b + plusminus * Math.sqrt(Math.pow(b,2) - 4 * a * c) ) / (2 * a);
};

// rounds to a certain amount of decimal places, but doesn't pad zeroes
Math.roundPlaces = function (number, places) {
    var factor = Math.pow(10, places);
    return Math.round(number * factor) / factor;
}

// determines percent error
Math.percentError = function (real, given) {
    var percent = Math.abs(real - given) / real * 100;
    return percent.toFixed(2);
}

// returns a random integer between two bounds
Math.randomInt = function (min, max) {
    return Math.round(Math.random() * (max - min) + min);
}

// Radians per Degrees
Math.RpD = Math.PI / 180;
