Math

  • Math class contains the all the floating point functions which are used for geometry and trigonometry, as well as several general-purpose methods.
  • It defines two constants E (2.72) and PI (3.14) and all the methods defined are static.

Trigonometric Functions

  • These functions takes parameter of type double as a angle in radius returns the result depends on the functions as sin(arg), cos(arg), tan(arg) these returns the sin, cosine and tan of the angle passed to it respectively.
  • asin(arg),acos(arg),atan(arg) returns the angle whose sin,cosine and tan of the specified argument is represents.
  • sinh(arg), cosh(arg), tanh(arg) returns the hyperbolic sin, cosine and tan of the specified argument.
  • All these functions returns the result as a type double and which are static methods.

Exponential Functions

  • These are the methods which takes the argument of type double and performs the exponential operations as cube root (cbrt), e of the argument (exp), natural logarithm of argument (log), base 10 logarithm(log10), power of two arguments (pow), square root (sqrt).

Rounding Functions

  • These methods performs various types of rounding operations such as absolute of long, int, float and double type argument,

  • ceil which returns the smallest whole number greater than or equal to double type argument where as floor returns the greatest whole number less than or equal to argument.

  • JDK8 adds a method called floorDiv which returns the floor value of the dividend/divisor.

  • max and min are the methods which returns the maximum and minimum values among the two arguments respectively.

  • round is the method which returns the nearest integer values for the argument of type double or float.
  • ulp is the method which returns units in the last place of the argument.

Miscellaneous Math Methods

  • These are the methods which perform increment, decrement, addition and subtraction operations which are defined in JDK8 with Exact suffix.
  • toRadius() is the method which converts degree to radius.
  • toDegree() is the method which converts radius to degree.

StrictMath

  • This class also defines the set of mathematical methods which are same as Math class methods but the difference is this version is to generate precisely identical results across all java implementations where as Math is to improve performance.

results matching ""

    No results matching ""