Computers are 2-state devices › Pulse – No pulse › On – Off Represented by › 1 – 0 BINARY
All data including › Numbers › Letters › Characters (,. = “ etc) › Graphics Must be changed to patterns of 1’s and 0’s to be stored in a Computer
Each column in a decimal number has a value 10x the column on it’s right So the number 345 i.e.10010U 3 45 Represents 3x100 +4x10 +5units =345
Each column in a binary number has a value 2x the column on it’s right So the binary number 1101 i.e.842U 1101 Represents 1x8 +1x4 +0x2 +1unit = 13 in decimal
Convert the binary numbers to decimal 42u42u u Convert these binary numbers to decimal = 1x4 +1 = 5 = 1x32 + 1x16 + 0x8 + 1x4 + 0x2 + 1 = 53 1) 11002) ) ) 122) 293) 39
Convert the Decimal numbers to Binary 21 = u = u Change these Decimal numbers to Binary 1) 152) 643)
Each character is represented by a unique pattern of 1’s and 0’s This code is called ASCII ASCII – American Standard Code for Information Interchange Each ASCII code is a pattern of 7 bits (and the 8 th bit used as a parity check) This allows 128 different possibilities A is represented by (or 65 in decimal) If more characters are required all 8 bits can be used allowing 256 possibilities
Unicode – Universal Character Set Unicode is a 16-bit code and can represent 65,536 characters This is designed to represent all the world’s major languages The first 128 characters are identical to ASCII (to allow compatibility) Advantage – represents more characters than ASCII Disadvantage – takes up more storage space
Smallest graphics dot on screen is called a PIXEL - Picture Element A Pixel can be lit or not lit Number of Pixels – RESOLUTION of graphic High resolution – lots of small pixels Low resolution – fewer larger pixels
Resolution measured in dpi (dots per inch) e.g. 300dpi 2 colours (monochrome) uses 1 bit per pixel › 1 – black 0 - white More colours need more bits per pixel › 2 bits – 4 colours represented by 00,01,10,11 › 3 bits – 8 colours (000,001,010,011,100,101,110,111) › 4 bits – 16 colours etc True Colour is represented by 24 bits and gives a range of 16,777,216 colours High resolution and lots of colours requires lots of memory To save memory one can be traded off against the other
Each 1 or 0 is called a BIT (short for Binary Digit). Eight bits are called a BYTE. 1024 (approx 1000) bytes is a KILOBYTE (Kb for short) 1024 kilobytes is a MEGABYTE (Mb for short) 1024 megabytes is a GIGABYTE (Gb for short) 1024 gigabytes is a TERABYTE (Tb for short) These units are used to measure the size of storage (called CAPACITY) or storage requirements e.g. the available memory, hard disk space, program size, file size.
Calculate the storage requirement for a black and white image 600 pixels by 850 pixels Answer – Total no of pixels = 600x850 = Each pixel is represented by 1 bit Storage required = bits = /8 bytes = bytes = 63750/1024 Kb = 62.3 Kb (to 1 Dec Pl)
Calculate the storage requirement for the following black and white graphics 1) An icon 16x24 pixels 2) A photograph 600 x400 pixels 3) A poster 2350 x 1876 pixels Answers 1) 48 bytes 2) 29.3 Kb 3) 0.53 Mb
Using 4 bits /- 4 2 u Max no in 4 bits Min no in 4 bits-7 +7 Number of values represented by 4 bits = 16 1 to +7, -1 to -7 (i.e. 14 values) and 2 values for 0 (i.e and 1000) Addition /- 4 2 u Addition gives the WRONG answer (should be 0)
Using 8 bits / u Examples – Using 8 bits Sign and Magnitude coding 1)Convert to Binary ) Convert to Decimal Because of the errors in addition and the 2 different codes to represent zero, Sign and Magnitude coding is not normally used
In 2’s Complement the Most Significant Bit (LHS) represents a NEGATIVE QUANTITY Using 4 bits u (-8+5) Max no in 4 bits Min no in 4 bits Number of values represented by 4 bits = 16 1 to +7, -1 to -8 (i.e. 15 values) and 1 value for 0 (i.e. 0000) Addition +3 +(-3) u = 0 √
Using 8 bits u ( ) Examples – Using 8 bits 2’s Complement coding 1)Convert to Binary ) Convert to Decimal ’s Complement is the type of coding normally used to represent Negative numbers
You can use the method of column headings to convert negative numbers to 2’s complement or you can use the following method To find -58 in 8-bit 2’s complement 58 Step 2 Change all 1’s to 0’s and 0’s to 1’s u Step 1 Convert +58 to binary Step 3 Add = -58 ( )
So far we have only dealt with INTEGERS (i.e. numbers without a fraction or decimal point) How would the computer cope with a Decimal Point? Consider Could be written x 1000 EXPONENT MANTISSA In Maths this is called Standard Form or Scientific Notation The Decimal Point is always moved to the same place and the result is always Mantissa x 10 to the power of Exponent Or x 10 3 In Computing we call it FLOATING POINT NOTATION
Computers can deal with very large and very small numbers by converting to Floating Point and storing the Mantissa and the Exponent as 2 separate numbers Examples – Use Floating Point to find the Mantissa and Exponent for each of the following 1) ) ) ) Mantissa = Exponent = +4 = x 10 4 = 9.87 x Mantissa = 9.87 Exponent = -2 = x 10 7 Mantissa = Exponent = +7 = 1.2 x Mantissa = 1.2 Exponent = -7
Binary Point u. ½ ¼ = in Decimal For Floating Point in Binary – Always move the Binary point before the first 1 = x 2 4 = x Mantissa = Exponent = 100 in Binary (As the point is always in the same place it can be missed out and the Mantissa stored as ) Usually - the Mantissa is stored in 4 bytes And the Exponent is stored in 1 byte
Negative Mantissa means – Negative Number Negative Exponent means – Fraction between 0 & 1 Increasing No of Bits for Exponent – Increases Range of numbers stored Increasing No of Bits for Mantissa – Increases Accuracy or Precision of numbers stored Convert the following to Floating point and state the Mantissa and Exponent (use 8-bit 2’s complement for Exponent in 3) 1) ) ) =.1011 x 2 10 M = 1011 E = 10 = x M = E = 110 =.1 x 2 -2 =.1 x M = 1 E = Convert each of the above numbers to decimal 1) 2.752) 45.53) 0.125
Long strings of 1’s and 0’s are difficult to remember HEXADECIMAL is a shorthand way of writing binary numbers HEX is Base 16 In binary – 4 bits can represent 16 different numbers Each of these numbers can be represented by a HEX digit HEX uses the digits 0-9 and A-F
DecimalBinary (4 bits)HEX etc A B C D E F
Group Binary in 4 bits Binary -> HexHex ->Binary D F C 3 B =183 E A =234 Decimal = 32
Convert the Hex numbers to Binary then Decimal 1) 48 2) E7 3)AB 4) 5C Convert the Decimal numbers to Binary then Hex 1) 135 2) 67 3)101 4) C Headings for columns in HEX (base 16) are etc (Each column heading is 16 times the column on it’s right)