LESSON OBJECTIVES
By the end of the lesson you should be able to;
Identify data types.
• Explain units of storage.
• Explain how characters are represented.
• Explain coding information using a bit pattern.
• Perform binary arithmetic.
• Convert from decimals to binary coded decimal and vice versa.
• Convert octal and hexadecimal numbers to binary, and vice versa
DANIEL OPOKU lawrence
[email protected] Data Representation
Refers to the methods used internally to represent
information stored in a computer. Computers can store
many different types of information: numbers, text,
graphics of many varieties (animation, video, and stills),
sound, etc.
DANIEL OPOKU lawrence
[email protected] Data Representation
All the types of information stored in a computer are
stored in the same simple format: a sequence of 0’s and
1’s. Computers use numeric codes to represent all the
information they store. Computers use a variety of
different codes, and they are all based on the binary
number system (base 2).
DANIEL OPOKU lawrence
[email protected] What is a data type?
It is an attribute of data, which tells the
compiler, or interpreter how the programmer
intends to use the data.
DANIEL OPOKU lawrence
[email protected] What is a data type?
Most programming languages support
various types of data, such as integer, string,
Boolean, floating point/real numbers,
character/char, date, tiny-text, text, blob,
varchar, etc
DANIEL OPOKU lawrence
[email protected] Integer data type
Integer is a data type that represent some range of
mathematical integers. For example, 193, -2, 24, 466 etc.
The width and ranges of these integer types vary widely
DANIEL OPOKU lawrence
[email protected] Boolean-data types
Boolean data simply refers to the logical structure of
how the language is interpreted to the machine
language. Thus, Boolean is used for logical values.
Boolean type represents the values true (1/one) and false
(0/zero)
DANIEL OPOKU lawrence
[email protected] Floating point - data types
Floating-point numbers, also known as real numbers, are used when
evaluating expressions that require fractional precision. For example,
calculations such as square root, or transcendental such as sine and
cosine, result in a value whose precision requires a floating-point type.
There are two kinds of floating-point types, float (single-precision
numbers) and double (double-precision numbers).
DANIEL OPOKU lawrence
[email protected] Strings - data types
Strings is a sequence of character that is alphanumeric character
(alphabet, digit, blank space, punctuation mark, etc.). For example,
Blinks, Dela123, $Abi, $!12D, etc.
DANIEL OPOKU lawrence
[email protected] DATA ORGANIZATION AND BIT PATTERN
WHAT WE SEE/HEAR INSIDE COMPUTERS
Text (e.g., a, b, c) 01100001, 01100010, 01100011
Number (e.g., 1, 2, 3) 00000001, 00000010, 00000011
Sound 0100110001010101000110100…
Image 1000100101010000000100111…
Video 0110000000001001101011001…
DANIEL OPOKU lawrence
[email protected] DATA ORGANIZATION AND BIT PATTERN
Computers generally work with some specific number of bits.
Common collections are;
single bits,
Groups of 4 bits (called nibbles),
3. Groups of 8 bits (called bytes),
4. Groups of 16 bits (called words), and more
DANIEL OPOKU lawrence
[email protected] HOW CHARACTERS ARE REPRESENTED
Computers can only deal with 0’s and 1’s (binary). All data that it
needs to work with (numbers, sounds, images, etc.) is first converted
into binary for the computer to be able to process. It’s exactly the
same for texts, or one piece of text known as character. Humans
interpret words and pictures; computers interpret only patterns of
bits. Each time you hit a key on a keyboard, the computer generates a
code for that letter, which is then processed by the CPU and the result
might be the letter appearing on the screen or being printed on
paper.
DANIEL OPOKU lawrence
[email protected] HOW CHARACTERS ARE REPRESENTED
Computers store data or information in bytes. A byte is defined as the amount of space it
takes to store a single character.
Name Abbreviation Approx. Bytes Exact Bytes
Byte B One 1 (or 8bits)
Kilobyte KB One thousand 1,024
Megabyte MB One million 1,048,576
Gigabyte GB One billion 1,073,741,824
DANIEL OPOKU lawrence
[email protected] CHARACTER CODES (CODING SCHEMES)
Representation of alphanumeric characters in bits 0’s and 1’s is done by character codes.
There are three widely used character codes
Binary Coded Decimal (BCD) – In this code, a 4-bit binary number represents each digit.
BCD is a way to express each of the decimal digits with a binary code.
Extended Binary Coded Decimal Interchange Code (EBCDIC) – It is an 8-bit code. In this
coding system, 256 different characters can be represented inside the computer
American Standard Code for Information Technology (ASCII) – It is a standard code to
represent alphanumeric data. The first ASCII was a 7-bit code. It was then extended to 8-
bits code. The 7-bits code system can represent 128 characters. The 8-bits code system
can represent 256 characters
DANIEL OPOKU lawrence
[email protected] BIT PATTERN REPRESENTATION (4-BIT REPRESENTATION)
BINARY DECIMALS HEXA
0000 0 0
0001 1 1
0010 2 2
0011 3 3
0100 4 4
0101 5 5
0110 6 6
0111 7 7
1000 8 8
1001 9 9
1010 10 A
1011 11 B
1100 12 C
1101
DANIEL OPOKU lawrence 13 D
[email protected] 1110 14 E
CONVERT FROM BINARY TO DECIMALS
Example 1
Convert 101012 to decimals
Example 2
Convert 100010012 to denary
DANIEL OPOKU lawrence
[email protected]