bit manipulation - Bitwise operations in PHP? -


I think bitwise action is required for very low level programming, such as writing device driver, lower level graphics , Communication Protocol Packet Assembly and Decoding I have been doing PHP for many years, and I have seen very little bitwive operations in PPP projects.

Can you give me examples of usage?

You can use it to encode a combination of things for bitmask. Actually, it works by giving each bit a meaning, so if you have 00000000 , then each bit represents something, besides having a single decimal number, suppose I have users There are some preferences for which I want to store, but in the case of storage my database is very limited. I could only store the decimal number and get it from that, which are chosen priorities, eg. 9 is 2 ^ 3 + 2 ^ 0 is 00001001 , hence the user's preference is 1 and the preference is 4 < / P>

  00000000 which means bin December. Example │││││││└ Priority 1 2 ^ 0 1 | Pref 1 + 2 Dec 3 00000011 is ││││││└─ Priority 2 2 ^ 1 2 | Pref1 + 8th December 12th is 10000001 │││││└── preference 3 2 ^ 2 4 | Pref 3,4 + 6 Dec 44 is 00101100 ││││└─── Priority 4 2 ^ 3 8 | All prefaces are December 255 11111111 │││└──── Priority 5 2 ^ 4 16 | ││└───── Priority 6 2 ^ 5 32 | Etc ... │└────── Priority 7 2 ^ 6 64 | └─────── Priority 8 2 ^ 7 128 |  

Read more


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -