In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces the rule analysis of shift operation in C++, which is very detailed and has certain reference value. Interested friends must finish reading it.
In programming, the shift operator is a kind of bit operator. The shift operator can translate numbers on a binary basis. According to the direction of translation and the rules for filling numbers, there are three types: (signed right shift) and > > (unsigned right shift).
A brief introduction to shift Operation
In C++, the shift operator has a binocular shift operator: (shift right). Expressions made up of shift operators are also arithmetic expressions, and their values are arithmetic values. The left shift operation is to move the Operand of a binary bit to the left according to the specified number of bits, the outgoing bit is discarded, and all the spaces moved on the right are filled by 0. The right shift operation is to move the Operand of a binary bit to the right according to the specified number of bits moved, the outgoing bit is discarded, and all the spaces moved on the left are filled by 0, or the symbol bit, depending on the machine. In a machine that uses a complement as a machine number, the symbol bit of a positive number is 0 and the symbol bit of a negative number is 1.
In the shift operation, the result of the shift of byte, short and char types will become the int type. For byte, short, char and int, the compiler does not make any optimization (unpredictable after optimization). It is stipulated that the actual number of moves is the number of moves and the remainder of 32, that is, the result of 33 shifts is the same as that of 1 shift. When moving the value of long, it is specified that the actual number of moves is the number of moves and the remainder of 64, that is, the result is the same as moving 66 times and moving twice.
The movement rules and use of the three shift operators are as follows:
Shift operation left shift operator
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.