Introduction to the SHL and SHR functions of Delphi

Source: Internet
Author: User

Format: Number of Shl/Shr mobile digits
Description: The operands and return values are both integers.
Example:

16 (10) = 10000 (2)
16 (10) Shr 1 = 10000 (2) Shr 1 = 1000 (2) = 8 (10)
16 (10) Shr 2 = 10000 (2) Shr 2 = 100 (2) = 4 (10)

Note:

An integer (I) shifts one digit left by bit, which is equivalent to multiplying it by 2, that is, I * 2
An integer (I) shifts one digit right by bit, which is equivalent to dividing it by 2, that is, I Div 2
An integer (I) shifts two places to the left by bit, which is equivalent to multiplying it by 2 and then by 2, that is, (I * 2) * 2
An integer (I) shifts two places to the right by bit, which is equivalent to dividing it by 2 and then Division 2, that is, (I Div 2) Div 2

Analysis:

Reference our most commonly used decimal description. If there is a number of 16, move one digit to the right in decimal, and 1 is left in the result. If one digit to the left is 160, it is equivalent to 16 Div 10 and 16*10;
Similarly, in binary, the sum of division and multiplication is 2.
The result is only an operation between the operand and the hexadecimal number.

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.