Common functions of the math class in Java

Source: Internet
Author: User
Tags abs float max in degrees natural logarithm square root

Brief introduction

The Java.lang.Math class contains methods for basic numeric manipulation, such as basic exponents, logarithms, square roots, and trigonometric functions.

class declaration

The following is a declaration of the Java.lang.Math class:

Public final class Math extends Object
Field

The following are the fields of the Java.lang.Math class:

    • static Double E --This is the double value, which is more recent than any other to E, the natural logarithm on the basis.

    • The static double PI --This is the double value, which is closer to the PI than any other, and the circumference of a circle is greater than its diameter.

Common methods:

S.N. Method & Description
1 Static double abs (double A)
This method returns the absolute value of a double.
2 Static float abs (float a)
This method returns the absolute value of a float.
3 static int abs (int a)
This method returns the absolute value of an int.
4 Static long abs (long a)
This method returns the absolute value of a long.
5 Static Double ACOs (double A)
This method returns the inverse cosine of a value that returns an angle range from 0.0 to pi.
6 Static double asin (double A)
This method returns a value of the inverse of the chord, which returns the range of angles from-PI/2 to PI/2.
7 Static Double Atan (double A)
This method returns the inverse tangent of a value that returns an angle range of-PI/2 to PI/2.
8 Static double atan2 (double y, double x)
This method returns the angle theta (x, Y) from the converted rectangle coordinates to the polar coordinates (r,θ).
9 Static double CBRT (double A)
This method returns the cube root of a double value.
10 Static double Ceil (double A)
This method returns the smallest (closest to negative infinity) Double value, greater than or equal to the parameter, and equals an integer.
11 Static double copysign (double magnitude, double sign)
This method returns the first floating-point parameter with the symbol of the second floating-point parameter.
12 static float copysign (float magnitude, float sign)
This method returns the first floating-point parameter with the symbol of the second floating-point parameter.
13 static double cos (double a)
This method returns the trigonometric cosine of a corner.
14 Static double cosh (double x)
This method returns the hyperbolic cosine of a double value.
15 Static double exp (double A)
This method returns the power of a double value of Euler's number E.
16 Static double expm1 (double x)
This method returns EX-1.
17 Static double floor (double a)
This method returns the largest (closest to positive infinity) Double value less than or equal to the parameter, and equals an integer.
18 static int getexponent (double D)
This method returns a double that is expressed in the unbiased exponent in the item.
19 static int getexponent (float f)
This method returns the unbiased exponent used in the representation of a floating-point number.
20 Static double Hypot (double x, double y)
This method returns the Sqrt (X2 +y2) without an intermediate overflow or underflow.
21st Static double IEEERemainder (double F1, double F2)
These two parameters, which are specified by the IEEE 754 standard, are computed for the remainder of the operation.
22 Static double log (double A)
This method returns the natural logarithm (base e) of a double value.
23 Static double log10 (double A)
This method returns a double value that is base 10.
24 Static double log1p (double x)
This method returns the sum of the natural logarithm of the parameter.
25 Static Double Max (double A, double b)
This method returns two of the larger double value.
26 static float Max (float A, float b)
This method returns the largest of the two floating-point values.
27 static int Max (int a, int b)
This method returns the largest of the two int values.
28 Static long Max (long A, long B)
This method returns the largest of the two long values.
29 Static Double min (double A, double b)
This method returns the two smaller double values.
30 static float min (float A, float b)
This method returns two smaller floating values.
31 static int min (int a, int b)
This method returns a value of two smaller int.
32 Static Long min (long a, long B)
This method returns a two smaller long value.
33 Static double Nextafter (double start, double direction)
This method returns the second parameter of the adjacent direction of a floating-point number, the first parameter.
34 static float Nextafter (float start, double direction)
This method returns the second parameter of the adjacent direction of a floating-point number, the first parameter.
35 Static Double Nextup (double D)
In the direction of positive infinity, this method returns a floating-point value adjacent to D.
36 static float Nextup (float f)
This method returns the floating-point value adjacent to F in the positive infinity direction.
37 Static Double pow (double A, double b)
The value of the first parameter returned by this method is raised to the power of the second argument
38 static double Random ()
The method returns an unsigned double value that is greater than or equal to 0.0 and less than 1.0.
39 Static double rint (double A)
The double value returned by this method, the parameter of the value is the closest, and is equal to an integer.
40 Static Long round (double a)
This method returns the closest parameter to a long.
41 static int round (float a)
This method returns the nearest integer of the parameter.
42 Static Double Scalb (double D, int scalefactor)
This method returns Dx2scalefactor rounding if a member of a double value group is rounded by a single, floating-point multiplication.
43 static float Scalb (float f, int scalefactor)
This method returns Fx2scalefactor rounding if the floating-point value collection is a member of a single, correctly rounded floating-point multiplication.
44 Static Double Signum (double D)
This method returns the parameter of the Signum function if the argument is 0 returns 0 if the argument is greater than 0 returns 1.0 if the argument is less than 0 to return-1.0.
45 static float Signum (float f)
This method returns the parameter of the Signum function if the argument is 0 returns 0 if the parameter is greater than 0 and returns 1.0f if the argument is less than 0 and returns -1.0f.
46 Static Double sin (double A)
This method returns the hyperbolic sine of a double value.
47 Static double Sinh (double x)
This method returns the hyperbolic sine of a double value.
48 Static double sqrt (double A)
This method returns the positive square root of a double value that is rounded correctly.
49 Static Double tan (double A)
This method returns the trigonometric function tangent of a corner
50 Static double Tanh (double x)
This method returns the hyperbolic tangent of a double value.
51 Static double Todegrees (double Angrad)
This method is roughly equal in angle, which is converted to radians measured in degrees.
52 Static double Toradians (double angdeg)
This method converts an angle, measured in degrees, to approximately equal angular radians.
53 Static double Ulp (double D)
This method returns the size of the ULP of the parameter.
54 Static double Ulp (float f)
This method returns the size of the ULP of the parameter.

Methods of inheritance

This class inherits the method from the following class:

    • Java.lang.Object

Common functions of the math class in Java

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.