Data Representation: Outline
Data Representation: Outline
Outline:
Number systems
binary
octal
hexadecimal
Representation of characters using codes
Other data types - audio, graphic, video
Representation of no’s
integer
floating point
Binary coded decimal
Programming languages and data types
Data representation
Decimal Hexadecimal
0,1,2…9 0,1,2…..9
10 A
11 B
12 C
13 D
14 E
15 F
Number Systems - Hexadecimal
3216 = ?
HEX BINARY
0 0000 Hex to binary:
1 0001
2 0010
1D7F16 = 0001 1101 0111 11112
3 0011
5AB216 = 0101 1010 1011 00102
4 0100
5 0101
6 0110
7 0111 Binary to hex:
8 1000
9 1001 1110 0011 0000 11002 = E30C16
A 1010
B 1011 1001 1000 1101 111116 = 98DF16
C 1100
D 1101
E 1110
F 1111
Decimal to Base-n Conversions
To convert from decimal to a different number base
such as octal, binary or hexadecimal involves
repeated division by that number base.
Keep dividing until the quotient is zero
Use the remainders in reverse order
Decimal to Octal Decimal to Hex
8 |674 16 |735
8 |84 2 (*80) 16 |45 F (*160)
8 |10 4 (*81) 16 | 2 D (*161)
8 | 1 2 (*82) 16 | 0 2 (*162)
8 | 0 1 (*83) 0
0
Answer: 12428 Answer: 2DF16
Goals of Computer Data Representation
ASCII
7-bit code (128 characters)
has an extended 8-bit version
used on PC’s and non-IBM mainframes
Was widely used to transfer data from one computer
to another – now being replaced by unicode
ASCII Coding Examples
An ASCII subset
“CAB” = 43414216
Symbol Code
= 0100 0011 0100 0001 0100 00102
A 41
B 42 “F1” = 463116
C 43 = 0100 0110 0011 00012
D 44
E 45
F 46 “3415” = 3334313516
0 30 = 0011 0011 0011 0100 0011 0001
1 31 0011 01012
2 32
3 33 *Note that this is a text string and no
4 34 arithmetic may be done on it. A postcode
5 35 is a good example of storing numbers as
6 36
7 37 text.
Alphanumeric Codes
EBCDIC
an 8-bit code (256 characters)
used on mainframe IBM machines