In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article is about how to learn about the iOS middle operation .md through the enumeration of Objective-C. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Bit operation
A bit operation is to operate or shift a binary number bit by bit. It consists of two operations: bit operation and shift. Let's learn more about these two operations.
Only the operators for all bit operations in iOS are discussed here. Operators with the same meaning in other languages may be different.
Bit operator (the following operators are all the same as Objective-C)
A type of bit operator includes the following:
~ (reverse, unary operator): it inverts each binary of the target number
Let initialBits: UInt8 = 0b00001111let invertedBits = ~ initialBits / / equals 11110000
| | (bitwise OR): it operates on the same position of two target digits. Rules: 0 and 0 are 0, 0 is 0, 1 is 1, and 1 is 1. 1 is 1. |
Let targetNum = 5 / / 101let targetNum2 = 6 / / 110print (targetNum | targetNum2) / / print 7//targetNum: 101//targetNum2: 110//result: 111 (decimal 7)
& (bitwise and): it operates on the same position of two target digits. The rules are: 0 and 0 for 0 and 1 for 1
Let targetNum = 5 / / 101let targetNum2 = 6 / / 110print (targetNum & targetNum2) / / print 4//targetNum: 101//targetNum2: 110//result: 100 (decimal 4)
^ (XOR): it performs XOR on the same position of the two target digits, and if different, the bit is 1, otherwise the bit is 0. Rules: if 0 and 0 are 0, 0 is 0, 0 is 1, 1 is 1, and 1 is 0.
Let targetNum = 5 / / 101let targetNum2 = 6 / / 110print (targetNum ^ targetNum2) / / print 3//targetNum: 101//targetNum2: 110//result: 011 (decimal 3)
Shift
> > (move to the right): it moves the target number to the right x bit by bit
Let targetNum = 5 / / 101print (targetNum > > 2) / / print 1//targetNum: 101 stroke / move 2 bits to the right / / result: 1 (decimal 1)
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.