In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
What is the basic knowledge of BigInteger? I believe many inexperienced people are at a loss about it. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
First of all, we know that basic types can only represent values within a certain range.
Byte (- 128127)
Long (- 92233720368547748089223372036854774807)
What should I do if it is out of range? For example, how to represent 123123456789123456789.
To correct it, signum has three values: 1, 1, 0, 0, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4
What is the definition of the mag array?
First of all, the binary corresponding to the large number 123123456789123456789 is 1101010110010101110011000111001110100011001110111000110011101110111110001010101. Every 32 bit bits from back to front can be stored as one int. This should be the most memory-saving representation, indicating that this large number takes up 16 bytes.
Char [] arr = {'1mlmlmlg2] arr = {' 1mlpl-2-lpmm3
The following is the algorithm for calculating the mag array, which is a very interesting process.
I believe you are already familiar with how to convert the string "123" to decimal shaping 123.
Public static void main (String [] args) {String a = "123"; char [] chars = a.toCharArray (); int sum = 0; int index = 0; while (index > > 32 is the first four bytes of x.
Num [2] = (int) x
Long x = num [1] + x > 32
Num [1] = (int) x
Long x = num [0] + x > 32
Num [0] = (int) x
2.2.2 int value of long sum = num [2] + group1
Num [2] = (int) sum
Sum = num [1] + sum > 32; possible carry
Num [1] = (int) sum
Sum = num [0] + sum > 32; there may be carry
Num [0] = (int) sum
Repeat the two procedures of 2.2 to represent a string (a large number) as an integer array.
There are also some very detailed problems, such as the size of the mag array. If it is small, it certainly cannot represent a large number, but if it is large, it will have no effect on the above algorithm. Finally, you only need to remove the item with a face value of 0 in front of the array.
(2 ^ n > 123123456789123456789 first find the minimum n and then [nbind 32] theoretically, but this is impossible, because 123123456789123456789 does not exist at all, and if it does, it does not need to be expressed.)
((length * 3402 > 10) + 1 + 31) > 5, why this can be used to estimate the length of mag, and it must be larger than or equal to the required length. I still don't understand that what is full of mystery is the best thing in the world.
I have seen these two processes many times before I slowly understand them.
The next question:
1: how do I restore the mag array to a string? This representation doesn't make any sense if it's irreversible.
2: how to realize addition, subtraction, multiplication and division.
After reading the above, have you mastered the basic knowledge of BigInteger? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.