diff --git a/LectureNote-bit.py b/LectureNote-bit.py new file mode 100644 index 0000000000000000000000000000000000000000..6928f8b4c0791b301e4df31c3993785522a21394 --- /dev/null +++ b/LectureNote-bit.py @@ -0,0 +1,67 @@ +Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 03:13:28) +[Clang 6.0 (clang-600.0.57)] on darwin +Type "help", "copyright", "credits" or "license()" for more information. +>>> a=240 +>>> bin(a) +'0b11110000' +>>> a +240 +>>> a<<2 +960 +>>> a>>2 +60 +>>> bin(a<<2) +'0b1111000000' +>>> bin(a>>2) +'0b111100' +>>> a=1 +>>> hex(a) +'0x1' +>>> hex(a<<1) +'0x2' +>>> hex(a<<2) +'0x4' +>>> a +1 +>>> hex(a<<5) +'0x20' +>>> b=255 +>>> hex(b) +'0xff' +>>> hex(b>>1) +'0x7f' +>>> hex(b>>2) +'0x3f' +>>> hex(b>>5) +'0x7' +>>> c=-255 +>>> hex(c) +'-0xff' +>>> hex(c>>1) +'-0x80' +>>> hex(c>>2) +'-0x40' +>>> hex(c>>5) +'-0x8' +>>> bin(-255) +'-0b11111111' +>>> a=255 +>>> bin(a) +'0b11111111' +>>> bin(-a) +'-0b11111111' +>>> a=-1 +>>> bin(a) +'-0b1' +>>> 9&10 +8 +>>> 9|10 +11 +>>> 9^10 +3 +>>> 10^9 +3 +>>> a=255 +>>> ~a +-256 +>>>