Java BigInteger class Knowledge points Summary

Source: Internet
Author: User

(1) The program sometimes needs to deal with large integers, and the BigInteger class in the Java.math package provides an integer operation of arbitrary precision, which can be constructed by using:

Public BigInteger (String VAL) constructs a decimal BigInteger object that can occur numberformatexception exceptions, that is, The numberformatexception exception occurs in the string parameter Val if it contains non-numeric characters.

(2) Common methods of BigInteger class:

Public BigInteger Add (BigInteger val) returns the current large integer object with the and of the large integer object specified by the parameter

Public BigInteger Subtract (BigInteger val) returns the difference between the current large integer object and the large integer object specified by the parameter

Public BigInteger Multiply (BigInteger val) returns the product of the large integer object specified by the current large integer object and the parameter

Public BigInteger devide (BigInteger val) returns the quotient of the current large integer object with the large integer object specified by the parameter

Public BigInteger remainder (BigInteger val) returns the remainder of the current large integer object and the large integer object specified by the parameter.

public int CompareTo (BigInteger val) Returns the result of the comparison of the current large integer object with the large integer object specified by the parameter, which is 1,-1, 0, respectively, representing the large integer that the current large integer object is greater than, less than, or equal to the specified parameter.

Public BigInteger ABS () returns the absolute value of the current large integer object

Public BigInteger pow (int exponent) returns the exponent power of the current large integer object.

The public string toString () returns the string representation of the current large integer object in decimal.

public string toString (int p) returns the string representation of the current large integer object P-binary.

(3)

Java BigInteger class Knowledge points Summary

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.