Big value in Java

Source: Internet
Author: User

If the basic data types in Java cannot meet the requirements, you can use the biginteger and bigdecimal classes,

Biginteger commonly used functions include:

Biginteger add (biginteger value)

Biginteger multiply (biginteger value)

Biginteger divide (biginteger value)

Biginteger Mod (biginteger value)

Int compareto (biginteger value) // if the two big integers are the same, 0 is returned; otherwise, 1 is returned.

These two classes use the static valueof method to convert a common data type to a large value. However, this type cannot be operated using simple ++, but the member function must be used.

Two simple usage methods

  biginteger A  =  biginteger. valueof (  520  ) 
biginteger C. a. add (B):
/// C = A + B, A and B must both be big integers.

bigdecimal and biginteger have similar usage, can refer to javadoc learning

reference materials

http://download.oracle.com/javase/1.4.2/docs/api/java/math/BigDecimal.html

http://download.oracle.com/javase/1.4.2/docs/api/java/math/BigInteger.html

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.