Large numbers in Java

Source: Internet
Author: User

In fact, the Java language does not model all objects in real life.

For example: real numbers. Java does not fully represent real numbers in life.

Integer.max_value: 2147483647

integer.min_value:-2147483648

If you exceed a number that represents less than 2147483648 or greater than 2147483647, you need to consider long


Long.max_value: 9223372036854775807

Long.min_value: -9223372036854775808


If long does not meet the requirements, BigInteger is required.

On the question of the King's reward for chess inventors, the first squares put 1 grains of wheat, the second one put 2 grains, and so on. Each of the cells is doubled from the previous one. The integer and long are not implemented correctly. Only with BigInteger.


Large numbers in Java

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.