Java's Math

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

First, the Math class
Java.lang.Math provides a series of static methods for scientific calculations, and its methods are generally double in terms of the number of parameters and the return value 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 arbitrary precision integers.


① Constructors
BigInteger (String val)
Frequent usage
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 the double class can be used for scientific calculations or project calculations. However, in the commercial calculation, it is required that the digital precision is higher, so the Java.math.BigDecimal class is used. The BigDecimal class supports fixed-point numbers regardless of precision.


Constructors
Public BigDecimal (double val)
Public BigDecimal (String val)
Frequent usage
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.