Php base bit calculus

Source: Internet
Author: User
Php base bit operation php bit operation $ a & amp; $ band (bitwise AND) $ a | $ bor (bitwise OR) $ a ^ $ bXor (by bit or )~ $ ANot (not by bit) $ a & lt; $ bShiftleft (left shift) $ a & gt; $ bShiftright (right shift) $ a & amp; $ B sets the bitwise of 1 in both $ a and $ B to 1. for example, bit operations based on php.
Php bitwise operations $ a & $ B and (bitwise and) $ a | $ B or (bitwise or) $ a ^ $ B Xor (bitwise Xor or )~ $ A Not (Not by bit) $ a <$ B Shift left (left Shift) $ a >$ B Shift right (right Shift) for details, set the bitwise of $ a & $ B to 1 and set the bitwise of $ a and $ B to 1. for example: 10 & 12 = 810 101012 11001000 8 $ a | $ B by bit or set one of $ a or $ B as 1. for example: 10 | 12 = 1410 101012 11001110 14 $ a ^ $ B by bit or for example: 10 ^ 1210 101012 11000110 6 ~ A sets the value of 0 in $ a as 1, 1, and 0 by bit. for example :~ 10 = 10 1010-11 $ a <$ B move left to move $ B from $ a to the left (each movement represents multiplied by 2). For example: 1 <10 = 10241 (1) shifts 10 digits left. 10000000000 (1024) is equivalent to the 10 power of 1*2. it is really depressing that php does not have a power operation. $ A >> B B shifts the right of $ a to the right of $ B (each movement is divided by 2). For example, 1024 <2 = 125610000000000 (1024) the 2-digit right shift is 100000000 (256). php calculates $ a & $ B and (bitwise and) $ a | $ B or (bitwise or) $ a ^ $ B Xor (bitwise Xor )~ $ A Not (Not by bit) $ a <$ B Shift left (left Shift) $ a >$ B Shift right (right Shift) for details, set the bitwise of $ a & $ B to 1 and set the bitwise of $ a and $ B to 1. for example: 10 & 12 = 810 101012 1100 8 $ a | $ B by bit or set one of $ a or $ B as 1. for example: 10 | 12 = 1410 101012 1100 14 $ a ^ $ B by bit or for example: 10 ^ 1110 1210 101012 1100 6 ~ A sets the value of 0 in $ a as 1, 1, and 0 by bit. for example :~ 10 = 10 1010-11 $ a <$ B move left to move $ B from $ a to the left (each movement represents multiplied by 2). For example: 1 <10 = 10241 (1) shifts 10 digits left. 10000000000 (1024) is equivalent to the 10 power of 1*2. it is really depressing that php does not have a power operation. $ A >> B B shifts the right of $ a to the right of $ B (each movement is divided by 2). For example, 1024 <2 = 125610000000000 (1024) the 2-digit right shift is 100000000 (256)

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.