ASP AND logic

xiaoxiao2021-03-06  122

This is a very interesting feature of the And operation. The AND operation is bites, 50 = 110010, 191 = 10111111, (110010) and (101111) = (110010), this is not equal to zero, so returns True, and 192 = (11000000), (110010) and (11000000) = 0, this is of course returning false. Another example 50 and 194 = True, because 194 = (11000010), (110010) and (11000010) = (10), so it is TRUE. In fact, this is the bit of the judgment 50's binary code and 191 binary code, and the same bit is 1. This is very useful.

For example, a system has 10 functions, one or a few items can be provided, we agree that the user's function is represented as a binary number, from the high to low, indicate whether the user has a certain function. Then the function of User A is 1000000000, which means that A only has the first function, and other functions have no right to access. User B function is 0100000000. Suppose the page X allows users to enter the user of 2 or 3 or 4 function permissions, then the page of the page will be written as 011000000 and userfunction 'userfunction for a user's functional permissions, when User A enters this page 0111000000 and 1000000000 = FALSE, Indicates that he doesn't have the right to enter this page user b. 0111000000 and 010000000000 = true, indicating that user b can enter this page but we will write 011000000 to 448, 1000000000 to 512, then page judgment is 448 And 512

转载请注明原文地址:https://www.9cbs.com/read-100497.html

New Post(0)