/*| (bitwise OR): X|y=z (z>=x, y), think of X, y bits one by one alignment, only corresponding to 1, take 1, and finally get the greater value of x, Y. "|" You can simply think of the operation operator & (bitwise AND) to get a larger value: X|y=z (z<=x, y), think of X, y bits one by one alignment, only corresponding to 0, take 0, and finally get the smaller value of x, Y. "&" can simply be considered as the operation operator >> (bitwise right SHIFT) to get a smaller value: X|y=z, think of x bits right shift y-bit (do not have the idea of a decimal point, think it is a pair of small points, hey, it has been bothering me), that is, from the end of x bits to erase y bits << (bitwise left): X|y=z, think of X's bits to the left Y-position, that is, at the end of x bits increase y 0. *///rgb color Merge int colormerge (int r,int g,int b) {//24-bit RGB value =R accounted for 8-bit +g accounted for 8-bit +b accounted for 8 bits//At bits end of R 16 0, added 8 0 at the end of bits of G, and finally, R, G, B of each A BITS take 1 return r << 16 | G << 8 | b;} RGB color split void colorseparate (int rgb) {///24-bit RGB value =R accounted for 8-bit +g 8-bit +b accounted for 8-bit int r = RGB >>16;//strip end 16 bits int g = RGB >>8 & 0xff;//0xff-->255--> consists of 8 1 bits, minus 8 bits at the end, int b = RGB & 0xFF;} UInt64 Createobjid (int platfromid,int serverid,int curtime,int seed) {//Create GUID//bits, seed (random seed) occupies 16 bits, curtime ( Timestamp) accounted for 32 bits, ServerID (server ID) accounted for 8 bits, PLATFROMID (platform ID) was randomly accounted for 8, total 64 bits UInt64 GUID = ((platfromid) << (8+32+16)) | ((ServerID) << (32 + 16)) | ((curtime) <<16) | ((Seed) (&0XFFFF); return GUID;}
[C + + basic] bit operation application--Create GUID