Professional Documents
Culture Documents
02-Data Representation in The Computer Systems
02-Data Representation in The Computer Systems
02-Data Representation in The Computer Systems
Foundation of IT Infrastructure
Week 02 - Data Representation 1
What is covered today?
• Performing Arithmetic:
• Addition, Subtraction
• Shifting
• Instructions – commands
1 0 1 1 0 1 0 1 2
= 128 + 0 + 32 + 16 + 0 + 4 + 0 + 1
= 18110
• https://www.mathwarehouse.com/programming/binary-nu
mbers-game/
Power of 2 to remember!
Decimal to Binary Conversion
Divide by target radix (2
in this case)
Remainders become digits in
the new representation
(0 <= digit < R)
Digits produced in right to left
order.
Quotient is used as next
dividend.
Stop when the quotient
becomes zero, but use the
corresponding remainder.
Decimal to Binary Conversion
Result = 1 1 0 0 0 0 12
Worksheet
435208 = 1000111010100002
Hexadecimal number system
DEC 0 1 2 3 4 5 6 7
HEX 0 1 2 3 4 5 6 7
DEC 8 9 10 11 12 13 14 15
HEX 8 9 A B C D E F
Decimal Hexadecimal Octal Binary
0 0 0 0000
1 1 1 0001
2 2 2 0010
3 3 3 0011
4 4 4 0100
5 5 5 0101
6 6 6 0110
7 7 7 0111
8 8 10 1000
9 9 11 1001
Decimal Hexadecimal Octal Binary
10 A 12 1010
11 B 13 1011
12 C 14 1100
13 D 15 1101
14 E 16 1110
15 F 17 1111
Converting Hex to Dec
1967/16 122 15 F
122/16 7 10 AF
7/16 0 7 7AF
• For example:
• the binary value 1010111110110010 will be written
as:
• 1010 1111 1011 0010 = 0xAFB2
Binary Addition
+ 0 1
0+0=0
0+1=1
1+0=1 0 0 1
1 + 1 = 10
1 1 10
Multiply Binary numbers
* 0 1
0*0=0
0*1=0
0 0 0
1*0=0
1*1=1
1 0 1
Additions with Binary numbers
1 0 1 1
× 1 0 1 0
---------------
0 0 0 0
1 0 1 1
0 0 0 0
1 0 1 1
------------------
1 1 01 1 1 0
Binary multiplication example
1 1 0 1 1 1
x 1 1 1
1 1 0 1 1 1
1 1 0 1 1 1
1 1 0 1 1 1
------------------------------------
1 1 0 0 0 0 0 0 1
ASCII Representation of Characters
Representation Interpretation
00100100
ASCII Code
$
Representing Text
• American Standard Code for Information
Interchange (ASCII)
• Developed from telegraph codes, alternative to IBM’s
Extended Binary Coded Decimal Interchange Code
(EBCDIC) in 1960s
• Printable and non-printable (ESC, DEL, …) characters
(127)
• Limited set of characters – many character missing,
especially language-specific
• Unicode – more than 110,000 characters covering 100
scripts
• UTF-8 is the form of Unicode which preserves the ASCII
encoding
Text: ASCII Characters
• ASCII: Maps 128 characters to 7-bit code.
00 nul 10 dle 20 sp 30 0 40 @ 50 P 60 ` 70 p
01 soh 11 dc1 21 ! 31 1 41 A 51 Q 61 a 71 q
02 stx 12 dc2 22 " 32 2 42 B 52 R 62 b 72 r
03 etx 13 dc3 23 # 33 3 43 C 53 S 63 c 73 s
04 eot 14 dc4 24 $ 34 4 44 D 54 T 64 d 74 t
05 enq 15 nak 25 % 35 5 45 E 55 U 65 e 75 u
06 ack 16 syn 26 & 36 6 46 F 56 V 66 f 76 v
07 bel 17 etb 27 ' 37 7 47 G 57 W 67 g 77 w
08 bs 18 can 28 ( 38 8 48 H 58 X 68 h 78 x
09 ht 19 em 29 ) 39 9 49 I 59 Y 69 i 79 y
0a nl 1a sub 2a * 3a : 4a J 5a Z 6a j 7a z
0b vt 1b esc 2b + 3b ; 4b K 5b [ 6b k 7b {
0c np 1c fs 2c , 3c < 4c L 5c \ 6c l 7c |
0d cr 1d gs 2d - 3d = 4d M 5d ] 6d m 7d }
0e so 1e rs 2e . 3e > 4e N 5e ^ 6e n 7e ~
0f si 1f us 2f / 3f ? 4f O 5f _ 6f o 7f del
ASCII Representation of Strings
48 65 6C 6C 6F 00 Computer uses
a terminating
H e l l o “NUL” byte of
all zeros at the
end of the
string.
41 75 53 4D 20 69 73 20 22 66 75 6E 22 21 00
A u S M i s “ f u n ” ! \0
How does computer store pictures
• It stores pixels and pixels.
Zoom
JPG vs GIF