Java's BigInteger class

Source: Internet
Author: User

1.BigInteger class overview

You can have data that is more than an integer range in operation.


How to construct a 2.BigInteger class

Public BigInteger (string val) converts the BigInteger decimal string representation to BigInteger

Package com;import java.math.biginteger;/** * biginteger class  *  You can have data that exceeds an integer range in arithmetic  *  construction methods  * public biginteger (String val)  *  member methods  * public biginteger add (Biginteger val)  * public BigInteger  Subtract (biginteger val)  * public biginteger multiply (biginteger val)  *  public biginteger divide (Biginteger val)  * public BigInteger[]  Divideandremainder (Biginteger val)   The first value returned is quotient   second value bit remainder  *  * */public  Class bigintegerdemo {public static void main (String[] args)  {BigInteger  b1 = new biginteger ("100"); Biginteger b2 = new biginteger ("$");//public biginteger add (BigInteger  val) System.out.println (B1.add (B2));//300system.out.println (B1.add (B2));//300system.out.println (B1.add (B2));// 300SystEm.out.println (B1.add (B2));//300//public biginteger subtract (Biginteger val) System.out.println ( B1.subtract (B2));//-100//public biginteger multiply (Biginteger val) System.out.println ( B1.multiply (B2));//20000//public biginteger divide (Biginteger val) System.out.println (B1.divide ( B2));//0//public biginteger[] divideandremainder (Biginteger val) biginteger[] bis =  b1.divideandremainder (B2); System.out.println (Bis[0]);//0system.out.println (bis[1]);//100}}



This article is from the "11831428" blog, please be sure to keep this source http://11841428.blog.51cto.com/11831428/1861230

Java's BigInteger class

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.