## Data Representation

All data on digital computers is represented as a sequence of 0s and 1s. This includes numeric data, text, executable files, images, audio, and video. The ASCII standard associates a seven bit binary number with each of 128 distinct characters. The MP3 file format rigidly specifies how to encode each raw audio file as a sequence of 0s and 1s. All data are numbers, and all numbers are data.

In this section we describe how to represent integers in binary, decimal, and hexadecimal and how to convert between different representations. We also describe how to represent negative integers.

Number systems.

There are many ways to represent integers: the number of days in the month of October can be represented as 31 in decimal, 11111 in binary, 1F in hexadecimal, or XXXI in Roman Numerals. It is important to remember than an integer is an integer, no matter whether it is represented in decimal or with Roman Numerals.

Binary Number

In mathematics and computer science, the binary numeral system, or base-2 numeral system, represents numeric values using two symbols: 0 and 1. More specifically, the usual base-2 system is a positional notation with a radix of 2. Numbers represented in this system are commonly called binary numbers

Computers are based on the binary (base 2) number system because each wire can be in one of two states (on or off)

#### Examples:

101012 = 10101B = 1×24+0×23+1×22+0×21+1×20 = 16+4+1= 21

101112 = 10111B = 1×24+0×23+1×22+1×21+1×20 = 16+4+2+1= 23

1000112 = 100011B = 1×25+0×24+0×23+0×22+1×21+1×20 =32+2+1= 35

decimal

We are most familiar with performing arithmetic with the decimal (base 10) number system. This number system has been widely adopted, in large part because we have 10 fingers. However, other number systems still persist in modern society.

decimal number system, also called Hindu-Arabic, or Arabic, number system,  in mathematics, positional numeral system employing 10 as the base and requiring 10 different numerals, the digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. It also requires a dot (decimal point) to represent decimal fractions. In this scheme, the numerals used in denoting a number take different place values depending upon position. In a base-10 system the number 543.21 represents the sum (5 × 102) +  (4 × 101) + (3 × 100) + (2 × 10−1) + (1 × 10−2).

Decimal numbers uses digits from 0..9.

These are the regular numbers that we use.

#### Example:

253810 = 2×103+5×102+3×101+8×100

Octal

Octal (pronounced AHK-tuhl , from Latin octo or “eight”) is a term that describes a base-8 number system. An octal number system consists of eight single-digit numbers: 0, 1, 2, 3, 4, 5, 6, and 7. The number after 7 is 10. The number after 17 is 20 and so forth.

The octal numeral system, or oct for short, is the base-8 number system, and uses the digits 0 to 7. Octal numerals can be made from binary numerals by grouping consecutive binary digits into groups of three (starting from the right). For example, the binary representation for decimal 74 is 1001010, which can be grouped into (00)1 001 010 – so the octal representation is 112.

In the decimal system each decimal place is a power of ten. For example:

In the octal system each place is a power of eight. For example:

By performing the calculation above in the familiar decimal system we see why 112 in octal is equal to 64+8+2 = 74 in decimal.

#### Examples:

278 = 2×81+7×80 = 16+7 = 23

308 = 3×81+0×80 = 24

43078 = 4×83+3×82+0×81+7×80 = 2247

In mathematics and computer science, hexadecimal (also base 16, or hex) is a positional numeral system with a radix, or base, of 16. It uses sixteen distinct symbols, most often the symbols 0–9 to represent values zero to nine, and A, B, C, D, E, F (or alternatively a–f) to represent values ten to fifteen. For example, the hexadecimal number 2AF3 is equal, in decimal, to (2 × 163) + (10 × 162) + (15 × 161) + (3 × 160), or 10995.

Each hexadecimal digit represents four binary digits (bits), and the primary use of hexadecimal notation is a human-friendly representation of binary-coded values in computing and digital electronics. One hexadecimal digit represents a nibble, which is half of an octet or byte (8 bits)

Hex numbers uses digits from 0..9 and A..F.

H denotes hex prefix.

#### Examples:

2816 = 28H = 2×161+8×16= 40

2F16 = 2FH = 2×161+15×16= 47

BC1216 = BC12H = 11×163+12×162+1×161+2×16= 48146

 Decimal Base-10 Binary Base-2 Octal Base-8 Hexadecimal Base-16 0 0 0 0 1 1 1 1 2 10 2 2 3 11 3 3 4 100 4 4 5 101 5 5 6 110 6 6 7 111 7 7 8 1000 10 8 9 1001 11 9 10 1010 12 A 11 1011 13 B 12 1100 14 C 13 1101 15 D 14 1110 16 E 15 1111 17 F 16 10000 20 10 17 10001 21 11 18 10010 22 12 19 10011 23 13 20 10100 24 14 21 10101 25 15 22 10110 26 16 23 10111 27 17 24 11000 30 18 25 11001 31 19 26 11010 32 1A 27 11011 33 1B 28 11100 34 1C 29 11101 35 1D 30 11110 36 1E 31 11111 37 1F 32 100000 40 20

Reference

http://www.willamette.edu/~gorr/classes/cs130/lectures/data_rep.htm

http://introcs.cs.princeton.edu/java/51data/

http://en.wikipedia.org/wiki/External_Data_Representation

http://guide.dhcuration.org/representation/

http://en.wikibooks.org/wiki/A-level_Computing/AQA/Problem_Solving,_Programming,_Data_Representation_and_Practical_Exercise/Fundamentals_of_Data_Representation/Binary_number_system

Name (required)

Email (required)

Feedback