Lecture Slides on Computer System Design unit 1


= .1001101 Convert Decimal 106.6015625 to Binary


Download 293.03 Kb.
bet3/4
Sana23.03.2023
Hajmi293.03 Kb.
#1287852
1   2   3   4
Bog'liq
SOC2040 SP WEEK 3 LECTURE SLIDES ON DATA REPRESENTATION SPRING 2023

= .1001101

Convert Decimal 106.6015625 to Binary
106.6015625 = 1101010.1001101

2|985 .
2|492 - 1
2|246 - 0
2|123 - 0
2| 61 - 1
2| 30 - 1
2| 15 - 0
2| 7 - 1
2| 3 - 1
2| 1 - 1
2| 0 - 1
 
= 1111011001

0.78357 x 2
1.56714 x 2 - 1
1.13428 x 2 - 1
0.26856 x 2 - 0
0.53712 x 2 - 0
1.07424 x 2 - 1
0.14848 x 2 - 0
0.29696 x 2 - 0
0.59392 x 2 - 0
1.18784 x 2 - 1
0.37568 x 2 - 0
0.75136 x 2 - 0
1.50272 x 2 - 1
1.00544 x 2 - 1
0.01088 x 2 - 0
0.02176 x 2 - 0
0.04352 x 2 - 0

= .1100100010011000

Convert Decimal 985.78357 to Binary
985.78357= 1111011001.1100100010011000

Binary Representation

  • Base 2 Number Representation
    • Represent 1521310 as 111011011011012
    • Represent 1.2010 as 1.0011001100110011[0011]…2
    • Represent 1.5213 X 104 as 1.11011011011012 X 213

Determine x in 104 = 2x
104 = 2x
log2104 = log2 2x
4 log210 = x log2 2 where log2 2 = 1
4 * 3.3219 = x where log210 = 3.32192809489
x = 13
Or 104 = 213
Determine x in 10x = 213
10x = 213
log1010x = log10 213
x log1010 = 13 log10 2 where log1010 = 1
x = 13*0.301 where log10 2 = 0.301029995664
x = 4
Or 104 = 213

Hexadecimal Number System

  • Hexadecimal Numbers :
  • 0,1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F

  • Each hexadecimal digit corresponds to four binary digits
  • Hex Number Binary coded hex

    0 0000

    1 0001

    2 0010

    3 0011

    4 0100

    5 0101

    6 0110

    7 0111

    8 1000

    9 1001

    A 1010

    B 1011

    C 1100

    D 1101

    E 1110

    F 1111

    Example : Binary ( 10110101)2 is Hex (B5)16

Hexadecimal Number System

  • Convert decimal 215 to Hex
  • (215)10 = (D7)16
  • Convert Hex D7 to Binary
  • (D7)16 = (11010111)2
  • Convert Hex D7 to Decimal
  • (D7)16 = D x 161 + 7 x 160
  • = 13 x 16 + 7 x 1 = (215)10


16|215 .
16| 13 - 7
16| 0 - D

Encoding Byte Values

  • Byte = 8 bits
    • Binary 000000002 to 111111112
    • Decimal: 010 to 25510
    • Hexadecimal 0016 to FF16
      • Base 16 number representation
      • Use characters ‘0’ to ‘9’ and ‘A’ to ‘F’
      • Write FA1D37B16 in C as
        • 0xFA1D37B
        • 0xfa1d37b
        • a = 0xfa1d37b; b=100; decimal

          b=0x100; hexadecimal = 256 decimal


0
0
0000
1
1
0001
2
2
0010
3
3
0011
4
4
0100
5
5
0101
6
6
0110
7
7
0111
8
8
1000
9
9
1001
A
10
1010
B
11
1011
C
12
1100
D
13
1101
E
14
1110
F
15
1111
Hex
Decimal
Binary

Octal Number System

  • Octal Numbers : 0,1, 2, 3, 4, 5, 6, 7
  • Each octal digit corresponds to three binary digits
  • Octal Number Binary coded Octal

    0 000

    1 001

    2 010

    3 011

    4 100

    5 101

    6 110

    7 111

    Example : Binary (100111101)2 is octal (475)8

Octal Number System

  • Convert decimal 215 to Octal
  • (215)10 = (327)8
  • Convert octal 327 to Binary
  • (327)8 = (011010111)2
  • Convert octal 327 to Decimal
  • (327)8 = 3 x 82 + 2 x 81 + 7 x 80
  • = 192 + 16 + 7 = (215)10


8|215 .
8| 26 - 7
8| 3 - 2
8| 0 - 3
Convert 0x879CEF to (i) Binary (ii) Decimal & (iii) Octal
(i) HEX2BIN(0x879CEF) = (1000011110011100 11101111)2
 
  • HEX2DEC(0x879CEF)

  • = 8 x 165 + 7 x 164 + 9 x 163 + C x 162 + E x 161 + F x 160
    = 8 x 1048576 + 7 x 65536+ 9 x 4096 + 12 x 256 + 14 x 16 + 15 x 1
    = 8388608 + 458752 + 36864 + 3072 + 224 + 15
    = 8887535
    (iii) HEX2OCT(0x879CEF) = 100001111001110011101111 = (41716357)8

Convert 0x4BAD6CAB to (i) Binary (ii) Decimal & (iii) Octal
(i) HEX2BIN(0x4BAD6CAB) = 01001011101011010110110010101011
 
  • HEX2DEC(0x4BAD6CAB)

  • = 4 x 167 + B x 166 + A x 165 + D x 164 + 6 x 163 + C x 162 + A x 161 + B x 160
    = 4 x 268435456 + 11 x 16777216 + 10 x 1048576 + 13 x 65536 + 6 x 4096 + 12 x 256 +
    10 x 16 + 11 x 1
    = +1073741824 + 184549376 + 10485760 + 851968 + 24576 +3072 + 160 +11
    = 1269656747
     
    (iii) HEX2OCT(0x4BAD6CAB)
    = 01001011101011010110110010101011= (11353266253)8

Convert Octal 36745412 to (i) Binary (ii) Decimal & (iii) Hexadecimal
(i)OCT2BIN(36745412) = 011110111100101100001010
(ii)OCT2DEC(36745412)
= 3 x 87 + 6 x 86 + 7 x 85 + 4 x 84 + 5 x 83 + 4 x 82 + 1 x 81 + 2 x 80
= 3 x 2097152+6 x 262144+ 7 x 32768+4 x 4096+5 x 512 + 4 x 64 + 1x8 + 2
= 6291456 + 1572864 + 229376 + 16384 + 2560 + 256 + 10
= 8112906
(iii) OCT2HEX(36745412) = 0111 1011 1100 1011 0000 1010= 0x7BCB0A
Convert Octal 753642532452 to (i) Binary (ii) Decimal & (iii) Hexadecimal
  • OCT2BIN(753642532452) = 111101011110100010101011010100101010


  • OCT2DEC(753642532452)

  • = 7 x 811 + 5 x 810 + 3 x 89 + 6 x 88 + 4 x 87 + 2 x 86 + 5 x 85 + 3 x 84 + 2 x 83 + 4 x 82 +
    5 x 81 + 2 x 80
    = 7*8589934592 + + 5*1073741824 + 3* 134217728 + 6 x 16777216 + 4 x 2097152 +
    2 x 262144 + 5 x 32768 + 3 x 4096 + 2 x 512 + 4 x 64 + 5 x 8+ 2
    = 60129542144 + 5368709120 + 402653184 + 100663296 + 8388608 + 524288+ 163840
    + 12288 + 1024 + 256 + 40 +2
    = 66010658090

  • OCT2HEX(753642532452)

  • = 111101011110100010101011010100101010 = 0xF5E8AB52A

Data Representations


C Data Type

Typical 32-bit

Typical 64-bit

x86-64


Download 293.03 Kb.

Do'stlaringiz bilan baham:
1   2   3   4




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling