The handling of integers in the point of a sword

Source: Internet
Author: User

First, the processing of the whole number of Parties

There are a few details to deal with when this is handled.

1. When the index is negative

2. When the exponential type is 0

3. Throw an exception when the condition is not met

One is often used to make a tree into a binary form, or to find the power of an integer or the power of a matrix.

This function is written by hand, so pay attention to jump out of the condition, the second use of recursion to achieve, third, with & Operation instead of the original operation, and before using the scope of the problem, will generally say that the parameter is n, but this n is how big it? Use the corresponding type to solve the operation of the corresponding scale

----------------------------------------------------------------------------the processing of the maximum number of bits from 1 to n---------------------------------- -------------------------------------------------------

When n is large, it cannot be processed with integers beyond the representation range of integers, when it is resolved from the angle of the string, while printing, looking for the boundary

One of the simplest ways is to compare each increment to the ' 999....99 ' to determine if it is equal, but the complexity is higher, and each comparison is a 0 (n) algorithm

The other is to determine whether the highest bit is rounded up after 1, if there is a rounding. So this number is the largest integer required.

The self-increment function

Another way to solve the problem is to use the idea of the whole arrangement in order to list the last item, so it is to use the idea of recursion to resolve the issue

The idea of using two functions is similar to the idea of a quick sort

The handling of integers in the point of a sword

Related Keywords:

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.