Java's Math

Source: Internet
Author: User
Tags natural logarithm pow square root

First, the Math class
Java.lang.Math provides a series of static methods for scientific calculation, and the parameters and return value types of the methods are generally double type.
ABS Absolute
Acos,asin,atan,cos,sin,tan Trigonometric Functions
sqrt square root
Pow (double a,doble b) a power of B
Log Natural logarithm
Exp e is the base index
Max (double a,double b)
Min (double a,double b)
Random () returns the number 0.0 to 1.0
Long round (double a) double type data A is converted to long (rounded)
Todegrees (double angrad) radians-angle
Toradians (double angdeg) angle, radians

Second, BigInteger class
Integer class as the wrapper class of int, the maximum integer value that can be stored is the numeric range of the 2^31-1,biginteger class than the number of the integer class
The range is much larger and can support integers of arbitrary precision.
① Constructors
BigInteger (String val)
Common methods
Public BigInteger ABS ()
Public BigInteger Add (BigInteger val)
Public BigInteger Subtract (BigInteger val)
Public BigInteger Multiply (BigInteger val)
Public BigInteger Divide (BigInteger val)
Public BigInteger remainder (BigInteger val)
Public BigInteger pow (int exponent)
Public biginteger[] Divdeandremainder (BigInteger val)

Third, BigDecimal class
The General float class and double class can be used for scientific calculation or engineering calculation, but in commercial calculation, it is required that the digital precision is higher, so it is used in the Java.math.BigDecimal class. The BigDecimal class supports fixed-point numbers of any precision.
Constructors
Public BigDecimal (double val)
Public BigDecimal (String val)
Common methods
Public BigDecimal Add (BigDecimal augend)
Public BigDecimal Subtract (BigDecimal subtrahend)
Public BigDecimal Multiply (BigDecimal multiplicand)
Public BigDecimal Divide (BigDecimal divisor, int scale, int roundingmode)

Java's Math

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.