vi xu ly 1

1.1 CAC HE THONG SO

-He dem thap phan(decimal)

-con goi la he dem co so 10

-dung muoi ky hieu:

1,2,3,4,5,6,7,8,9,0

-vd:

Ba nghin chin tram bay muoi tam

3978=3×10³+9×10²+7×10¹+8×10º

=3000+900+70+8

-he dem nhi phan(binary)

-con goi he dem co so 2

-su dung 2 ky hieu(bit):0va 1

SO NHI PHAN

-moi ky hieu 0 hoac 1 goi la bit(binay digit-chu so nhi phan)

-kich co cua so nhi phan goi la so bit cua no

-MSB(most significant bit):bit sat trai

-LSB(least significant bit):bit sat phai

-vd:1010101010101010

↑ ↑

MSB LSB

La mot so nhi phan 16 bit

SO NHI PHAN KO DAU

-chi bieu dien duoc cac gia tri ko am(≥0)

Voi n-bit co the bieu dien cac gia tri tu o den 2mu n-1

-vd:gia tri v cua so nhi phan ko dau 1101 duoc tinh:

V(1101)=1×2³+1×2²+0×2¹+1×2º

=8+4+0+1=13

Tong quat:neu so nhi phan N n-bit:

N=b(n-1)b(n-2)....b1b0

Thi gia tri V cua no la

V=b(n-1)×2mu n-1+b(n-2)×2mu n-2+....+b1×2¹+b0×2º

Cac so nhi phan ko dau 4 bit bieu dien duoc cac gia tri tu? Den?

16 gia tri tu 0 den 15

0000 0

0001 1

0010 2

0011 3

0100 4

0101 5

0110 6

0111 7

1000 8

1001 9

1010 10

1011 11

1100 12

1101 13

1110 14

1111 15

Dai gia tri cac so ko dau 8 bit la:[0,255](unsigned char trong C)

Dai gia tri cac so ko dau 16 bit la:[0,65535](unsigned int trong C)

Vd:chuyen doi 25 sang nhi phan ko dau

Chia 2 thuong so du so

25/2 = 12 1 LSB

12/2 = 6 0

6/2 = 3 0

3/2 = 1 1

1/2 = 0 1 MSB

Ket qua la:10011

SO NHI PHAN CO DAU

-bieu dien duoc ca cac gia tri am

-con goi la so bu hai

-voi n bit co the bieu dien duoc cac gia tri tu am2mu n-1 den 2mu (n-1)-1

Vd:gia tri V cua so nhi phan co dau 1101 duoc tinh

V(1101)= -1×2³+1×2²+0×2¹+1×2º

= -8+4+0+1= -3

Tong quat:neu so nhi phan N n-bit:

N=b(n-1)b(n-2)....b1b0

Thi gia tri V cua no la

V= -b(n-1)×2mu n-1+b(n-2)×2mu n-2+....+b1×2¹+b0×2º

16 gia tri tu -8den 7

0000 0

0001 1

0010 2

0011 3

0100 4

0101 5

0110 6

0111 7

1000 8

1001 9

1010 10

1011 11

1100 12

1101 13

1110 14

1111 15

Dai gia tri cac so ko dau 8 bit la:[-128,+127](char trong C)

Dai gia tri cac so ko dau 16 bit la:[-32768,+32767]( int trong C)

Tim doi so(lay bu 2)

Tong cua mot so voi doi so cua no bang 0

-vd:doi so cua so nhi phan co dau 10011101?

10011101 so co dau(-99)

01100010 lay bu 1

+ 1 cong 1

-----------

01100011 ket qua (+99)

Bạn đang đọc truyện trên: AzTruyen.Top

Tags: #dfd