Skip to main content

Math Module

The math module can be imported with the name math and has the following static properties:

  • PI - Ratio of a circle's circumference to its diameter; approximately 3.14159
  • E - Euler's constant and the base of natural logarithms; approximately 2.718
  • PHI - Golden Ratio; approximately 1.618
  • SQRT2 - Square root of 2; approximately 1.414

The math module also has the following methods:

  • absolute(num) - Returns the absolute value of a number
  • round(num) - Returns the nearest integer to a number
  • floor(num) - Returns the largest integer less than or equal to a number
  • ceil(num) - Returns the smallest integer greater than or equal to a number
  • sin(num) - Returns the sine of a number
  • cos(num) - Returns the cosine of a number
  • tan(num) - Returns the tangent of a number
  • asin(num) - Returns the arcsine of a number
  • acos(num) - Returns the arccosine of a number
  • atan(num) - Returns the arctangent of a number
  • radtodeg(num) - Converts a number in radians to degrees
  • degtorad(num) - Converts a in degrees to radians
  • log([num], <root>) - Returns the logarithm of a number to a specified base. If no base is provided, it will use the default log base, e
  • sqrt(num) - Returns the square root of a number
  • power([num], [exponent]) - Returns the value of a number raised to a specified power
  • root([num], [root]) - Returns the root of a number to a specified root.
  • factorial(num) - Returns the factorial of a number
  • min([num, num...]) - Returns the minimum value of its inputs
  • max([num, num...]) - Returns the maximum value of its inputs