Binary Hexadecimal Conversion

01-05 word bytes bits

http://www.plcdev.com/plc_basics/number_systems_and_codes/binary_people_learning_your_1s_and_0s

翻译及转换方法

bit    位

nibble(4bits)  半字节

byte(8bits)  字节

word(16bits) 双字节

dword(32bits) 4字节

 

二进制表示上图(共16位)

1011100110101011

 

八进制(3位做为1位)

1-011-100-110-101-011

=>o 1-3-4-6-5-3

=>o134653

 

十六进制(4位做为1位)

1011-1001-1010-1011

=>0x B-9-A-B

=>0xB9AB

 

转换表

二进制   2进制    16进制   10进制

2^0  = 0b0000-0001 = 0x0001 = 1

2^1  = 0b0000-0010 = 0x0002 = 2

2^2  = 0b0000-0100 = 0x0004 = 4

2^3  = 0b0000-1000 = 0x0008 = 8



2^4  = 0b0001-0000 = 0x0010 = 16

2^5  = 0b0010-0000 = 0x0020 = 32

2^6  = 0b0100-0000 = 0x0040 = 64

2^7  = 0b1000-0000 = 0x0080 = 128



2^8  = 0b0000-0001-0000-0000 = 0x0100 = 256

2^9  = 0b0000-0010-0000-0000 = 0x0200 = 512

2^10 = 0b0000-0100-0000-0000 = 0x0400 = 1024

2^11 = 0b0000-1000-0000-0000 = 0x0800 = 2048



2^12 = 0b0001-0000-0000-0000 = 0x1000 = 4096

2^13 = 0b0010-0000-0000-0000 = 0x2000 = 8192

2^14 = 0b0100-0000-0000-0000 = 0x4000 = 16384

2^15 = 0b1000-0000-0000-0000 = 0x8000 = 32768



2^16 = 0b0000-0001-0000-0000-0000-0000 = 0x0001-0000 = 65536

2^17 = 0b0000-0010-0000-0000-0000-0000 = 0x0002-0000 = 131072

2^18 = 0b0000-0100-0000-0000-0000-0000 = 0x0004-0000 = 262144

2^19 = 0b0000-1000-0000-0000-0000-0000 = 0x0008-0000 = 524288



2^20 = 0b0001-0000-0000-0000-0000-0000 = 0x0010-0000 = 1048576

2^21 = 0b0010-0000-0000-0000-0000-0000 = 0x0020-0000 = 2097152

2^22 = 0b0100-0000-0000-0000-0000-0000 = 0x0040-0000 = 4194304

2^23 = 0b1000-0000-0000-0000-0000-0000 = 0x0080-0000 = 8388608



2^24 = 0b0000-0001-0000-0000-0000-0000-0000-0000 = 0x0100-0000 = 16777216

2^25 = 0b0000-0010-0000-0000-0000-0000-0000-0000 = 0x0200-0000 = 33554432

2^26 = 0b0000-0100-0000-0000-0000-0000-0000-0000 = 0x0400-0000 = 67108864

2^27 = 0b0000-1000-0000-0000-0000-0000-0000-0000 = 0x0800-0000 = 134217728



2^28 = 0b0001-0000-0000-0000-0000-0000-0000-0000 = 0x1000-0000 = 268435456

2^29 = 0b0010-0000-0000-0000-0000-0000-0000-0000 = 0x2000-0000 = 536870912

2^30 = 0b0100-0000-0000-0000-0000-0000-0000-0000 = 0x4000-0000 = 1073741824

2^31 = 0b1000-0000-0000-0000-0000-0000-0000-0000 = 0x8000-0000 = 2147483648



(2^32-1) = 0xffff-ffff = 4294967295

你可能感兴趣的:(conversion)