Data Representation Int 2 Computing Unit 1 – Computer Systems St Kentigern’s Academy
Data Representation Binary Code Measuring storage Representing numbers Representing text Representing graphics
Binary Codes What is binary anyway? binary means "two state“; binary codes are made from two symbols only; 1 and 0; electronic computers have many circuits that switch ON and OFF; if electricity is sent along a wire it is represented by a 1 and if electricity is not sent along a wire it is represented by a 0.
Binary Codes why do computers use binary (rather then decimal)? binary values 1 and 0 match exactly to circuits switched ON and OFF; circuits that work with only two symbols are very simple, that makes them fast at working and cheaper to make; the rules for adding and calculating binary are few, again that makes the ALU simple and cheap to make.
Representing Numbers Advantages of using Binary Binary is a simple two-state system (1 or 0) which is ideal when representing a two-state system of “power on/power off” A degraded signal can still be detected as representing 1 There are only a few rules of addition, making calculations simpler
Measuring Storage AbbrTermMeaning bbita single binary digit, 0 or 1 Bbyte8 bits Kbkilobyte1024 bytes Mbmegabyte1024 kb Gbgigabyte1024 mb Tbterabyte1024 gb
Converting between units To change: Bits to bytes, divide by 8 Bytes to bits, multiply by 8 Bytes to kilobytes, divide by 1024 Kilobytes to bytes, multiply by 1024 Kilobytes to megabytes, divide by 1024 Megabytes to kilobytes, multiply by 1024 Megabytes to gigabytes, divide by 1024 Gigabytes to megabytes, multiply by 1024 Gigabytes to terabytes, divide by 1024 Terabytes to gigabytes, multiply by 1024
Measuring Storage How to remember storage: Bit, Big Byte, Bottoms Kilobyte, Kill Megabyte, Many Gigabyte, Grey TerabyteToads
Measuring Storage Backing Storage Capacity Floppy Disk – 1.44mb CD – 750mb DVD – 4.6gb Hard Drive – 180gb Tape Drive – 180gb Memory Capacity RAM – 2gb
Representing Numbers We use decimal to count – Th,H,T,U We start with 1 and multiply it by 10 to get Ten’s; we multiply this by 10 to get Hundreds and so on… HThTThThHTU = =10220
Representing Numbers Computers don’t use Base 10 they use base 2. So we start with 1 and multiply it by 2 to get 2, we multiply this by 2 to get 4 and so on… U = =79
Converting decimal to binary If we have a decimal number, e.g. 28, we look to see what numbers in the headings make up our decimal number when added. So = 28 We put a binary 1 under the 16, 8 and 4, and a binary 0 under the other headings U = = 72
Converting Binary to decimal If we have a binary number, e.g , we put the numbers under the corresponding headings. Where ever there is a 1 we add up the headings. So = U = = 74
Representing Numbers A 4-bit system has 4 headings : U = U 1111= 15 An 8-bit system has 8 headings :
What do the Headings Mean? When we talk about the bit size we mean the number of bits assigned to represent data. If we have 2 bits, we have 2 headings which gives us 2 2 = 4 different binary patterns. If we have 3 bits, we have 3 headings which gives us 2 3 = 8 different binary patterns: 2U42U
Binary/Decimal Conversion Convert the following to binary: Convert the following to decimal: Remember your headings
Real Numbers Very large and very small numbers would take up too much space in memory so a different technique called floating point representation is used to store these numbers Real number are numbers with a decimal point and are represented using floating point. The number contains a mantissa and exponent. The mantissa is the number. The exponent is where the point is placed. The rule is to place the binary point in front of the digits and to count the number of places that it has been move.
Real Numbers Example – What do we do with a decimal point? 12.4 =.124 *10 2 = * is called the mantissa 0010 is called the exponent And both of these numbers are stored in memory.
AscII – Text representation American Standard Code for Information Interchange: The ASCII system was introduced so that all computers use the same binary code to represent the computers character set – all the letters, numbers and symbols that can be displayed by the computer. ASCII gives each character a unique number which can easily be changed into binary: A = 65 = The ASCII system standardises computers, therefore making text files compatible with a wider range of computer systems.
ASCII ASCII is a 7-bit code which provides 2 7 = 128 code values. But as we study 8-bit systems at Int 2 we put a 0 in front of the ASCII code. This allows 96 characters and 32 control characters – these characters do not print anything on the screen, they control certain operations of the computer system, e.g. cursor keys. Here is part of the ASCII table: CharacterASCII codeDecimal A B Z a 2 Beep &
Question time 1. What is a character set? 2. What is a control character? 3. What does ASCII stand for? 4. How many characters can ASCII represent? 5. Explain how real numbers are represented in binary.
Representing graphics Computers store graphical images in memory, on backing storage devices and display them on the monitor as bit maps. A picture cell or pixel is the most basic component of any computer graphic. Every computer graphic is made up of a grid of pixels. The computer represents the image in memory as a file of 0s and 1s White pixels are represented by a 0 and black pixels by a 1 The file is known as a bit map
Representing graphics There is a one-to-one relationship between the pixels and the bit pattern
Graphics - Resolution The quality of a graphical image is directly related to the number of pixels used to produce it. A good quality image will have many small pixels, e.g. a photo A poor quality image will have few large pixels, e.g. teletext The density of pixels is called the resolution of the image. This is measured in dots per inch (dpi). The higher the resolution, the more pixels, the better the quality of the graphic, but the more storage required to store the graphic.
Graphic Calculations In a black and white image each pixel is represented by 1 bit. We want to calculate the storage requirements for an image that has a dpi of 1200dpi and has a length of 5 inches and a breadth of 4 inches. Number of pixels in length= 1200 x 5 = 6000 pixels Number of pixels in breadth= 1200 x 4 = 4800 pixels Total no of pixels= 6000 x 4800 = 28,800,000 pixels 1 pixel needs 1 bit of data storage = 28,800,000 bits /8 to get bytes= 3,600,000 bytes /1024 to get kb= Kb /1024 to get mb= 3.46 Mb
Question time 1. What does the term resolution mean? 2. Describe how a graphic is represented in binary. 3. Calculate the following graphics storage requirements: dpi, 4” by 5” dpi, 5” by 7” pixels by 1200pixels