On-Machine topic (beginner)-The mantissa of high-order number (Java)

Source: Internet
Author: User

The topics are as follows:


The code is as follows:

Package Huawei;public Final class Demo {/* function: The last three digits of the N-side of the solution M (M,n are greater than 10) input parameters:    int m:m >    int n = > 10 return value: 
  
   m the last three digits of the N-th-square */public the static int getlast3digitsofmn (int M, int N) {int result = 1;    for (int i = 0;i < N;++i) {        result = (Result * (M%))%;    }    return result;}}
  
When M, n is large, the n-th of M cannot be represented with the basic data type ... The analysis can be found that the last three bits of the product are only related to the multiplier and the last three bits of the multiplier, but not to the high level, so each time the product result is 1000 modulo ...


Use the loop to find the N-square of M, each multiplication after the first divided by 1000 to take the remainder, otherwise it will result in data overflow, this topic is to test this knowledge point (data overflow).

On-Machine topic (beginner)-The mantissa of high-order number (Java)

Related Article

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.