Math Class Methods List

htt‮w//:sp‬ww.theitroad.com

Here is a list of some commonly used methods of the Math class:

  1. abs(x): Returns the absolute value of x.

  2. ceil(x): Returns the smallest integer greater than or equal to x.

  3. cos(x): Returns the cosine of x (x is in radians).

  4. exp(x): Returns the value of e raised to the power of x.

  5. floor(x): Returns the largest integer less than or equal to x.

  6. log(x): Returns the natural logarithm (base e) of x.

  7. max(x, y): Returns the larger of x and y.

  8. min(x, y): Returns the smaller of x and y.

  9. pow(x, y): Returns the value of x raised to the power of y.

  10. random(): Returns a random double value between 0.0 and 1.0.

  11. round(x): Returns the closest long or int value to x.

  12. sin(x): Returns the sine of x (x is in radians).

  13. sqrt(x): Returns the positive square root of x.

  14. tan(x): Returns the tangent of x (x is in radians).

  15. toDegrees(x): Converts an angle measured in radians to an approximately equivalent angle measured in degrees.

  16. toRadians(x): Converts an angle measured in degrees to an approximately equivalent angle measured in radians.

  17. floorDiv(x, y): Returns the largest (closest to positive infinity) int value that is less than or equal to the algebraic quotient.

  18. floorMod(x, y): Returns the floor modulus of the given arguments.

  19. ulp(x): Returns the size of the ulp (units in the last place) of the argument.

  20. signum(x): Returns the signum function of the argument; zero if the argument is zero, 1.0 if the argument is greater than zero, -1.0 if the argument is less than zero.

These methods can be used in various mathematical operations, such as calculating absolute values, rounding numbers, calculating trigonometric functions, finding the maximum and minimum values, and more.