The int type is used to implement the right shift operation of the unsingedint type. Many scripting languages do not contain unsingedint, such as PHP. Bitwise operations generally have no difference between int and unsingedint. except for the right shift operation, in int, replace 1 has many scripting languages without unsinged int, such as PHP. Bit operations generally have no difference between int and unsinged int, except for the right shift operation. in int, 1 is supplemented and 0 is supplemented in unsinged int. I 've been thinking for a long time, finally, I thought of a better method, but the number of shifts to the right of this method must be at least 1. In general, 0 shifted right is meaningless.
($ A> 1) & 0x7fffffff)> ($ n-1) Here $ n is the number of shifts to the right. $ N> = 1
For example, to implement md5 encryption, the following function is generally used, which can be implemented in PHP as follows:
Copy to ClipboardReference: [www.bkjia.com] function RotateLeft ($ a, $ n)
{
Return ($ a <$ n) | ($ a> 1) & 0x7fffffff)> (31-$ n); pay attention to the operator priority.
}
People who are interested in encryption and decryption should have encountered the same problems as me. I don't know if anyone has a better solution.
There are no unsinged int values for containers, such as PHP. Bit operations generally have no difference between int and unsinged int. apart from the right shift operation, the int is supplemented by 1...