# Java.lang.Math Class

## Introduction

The **java.lang.Math** class contains methods for performing basic numeric operations such as the elementary exponential, logarithm, square root, and trigonometric functions.

## Class declaration

Following is the declaration for **java.lang.Math** class:

public final class Math extends Object

## Field

Following are the fields for **java.lang.Math** class:

**static double E**-- This is the double value that is closer than any other to e, the base of the natural logarithms.**static double PI**-- This is the double value that is closer than any other to pi, the ratio of the circumference of a circle to its diameter.

## Class methods

S.N. | Method & Description |
---|---|

1 |
This method returns the absolute value of a double value. |

2 |
This method returns the absolute value of a float value. |

3 |
This method returns the absolute value of an int value. |

4 |
This method returns the absolute value of a long value. |

5 |
This method returns the arc cosine of a value; the returned angle is in the range 0.0 through pi. |

6 |
This method returns the arc sine of a value; the returned angle is in the range -pi/2 through pi/2. |

7 |
This method returns the arc tangent of a value; the returned angle is in the range -pi/2 through pi/2. |

8 |
static double atan2(double y, double x) This method returns the angle theta from the conversion of rectangular coordinates (x, y) to polar coordinates (r, theta). |

9 |
This method returns the cube root of a double value. |

10 |
This method returns the smallest (closest to negative infinity) double value that is greater than or equal to the argument and is equal to a mathematical integer. |

11 |
static double copySign(double magnitude, double sign) This method returns the first floating-point argument with the sign of the second floating-point argument. |

12 |
static float copySign(float magnitude, float sign) This method returns the first floating-point argument with the sign of the second floating-point argument. |

13 |
This method returns the trigonometric cosine of an angle. |

14 |
This method returns the hyperbolic cosine of a double value. |

15 |
This method returns Euler's number e raised to the power of a double value. |

16 |
This method returns e |

17 |
This method returns the largest (closest to positive infinity) double value that is less than or equal to the argument and is equal to a mathematical integer. |

18 |
static int getExponent(double d) This method returns the unbiased exponent used in the representation of a double. |

19 |
static int getExponent(float f) This method returns the unbiased exponent used in the representation of a float. |

20 |
static double hypot(double x, double y) This method returns sqrt(x |

21 |
static double IEEEremainder(double f1, double f2) This method computes the remainder operation on two arguments as prescribed by the IEEE 754 standard. |

22 |
This method returns the natural logarithm (base e) of a double value. |

23 |
This method returns the base 10 logarithm of a double value. |

24 |
This method returns the natural logarithm of the sum of the argument and 1. |

25 |
static double max(double a, double b) This method returns the greater of two double values. |

26 |
static float max(float a, float b) This method returns the greater of two float values. |

27 |
This method returns the greater of two int values. |

28 |
static long max(long a, long b) This method returns the greater of two long values. |

29 |
static double min(double a, double b) This method returns the smaller of two double values. |

30 |
static float min(float a, float b) This method returns the smaller of two float values. |

31 |
This method returns the smaller of two int values. |

32 |
static long min(long a, long b) This method returns the smaller of two long values. |

33 |
static double nextAfter(double start, double direction) This method returns the floating-point number adjacent to the first argument in the direction of the second argument. |

34 |
static float nextAfter(float start, double direction) This method returns the floating-point number adjacent to the first argument in the direction of the second argument. |

35 |
static double nextUp(double d) This method returns the floating-point value adjacent to d in the direction of positive infinity. |

36 |
This method returns the floating-point value adjacent to f in the direction of positive infinity. |

37 |
static double pow(double a, double b) This method returns the value of the first argument raised to the power of the second argument. |

38 |
This method returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0. |

39 |
This method returns the double value that is closest in value to the argument and is equal to a mathematical integer. |

40 |
This method returns the closest long to the argument. |

41 |
This method returns the closest int to the argument. |

42 |
static double scalb(double d, int scaleFactor) This method returns d × 2 |

43 |
static float scalb(float f, int scaleFactor) This method return f × 2 |

44 |
static double signum(double d) This method 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. |

45 |
This method returns the signum function of the argument; zero if the argument is zero, 1.0f if the argument is greater than zero, -1.0f if the argument is less than zero. |

46 |
This method returns the hyperbolic sine of a double value. |

47 |
This method Returns the hyperbolic sine of a double value. |

48 |
This method returns the correctly rounded positive square root of a double value. |

49 |
This method returns the trigonometric tangent of an angle.r |

50 |
This method returns the hyperbolic tangent of a double value. |

51 |
static double toDegrees(double angrad) This method converts an angle measured in radians to an approximately equivalent angle measured in degrees. |

52 |
static double toRadians(double angdeg) This method converts an angle measured in degrees to an approximately equivalent angle measured in radians. |

53 |
This method returns the size of an ulp of the argument. |

54 |
This method returns the size of an ulp of the argument. |

## Methods inherited

This class inherits methods from the following classes:

java.lang.Object