Presentation is loading. Please wait.

Presentation is loading. Please wait.

Extending Binary In today’s lesson we will look at: representing different types of numbers possible errors binary coded decimal (BCD) comparing BCD with.

Similar presentations


Presentation on theme: "Extending Binary In today’s lesson we will look at: representing different types of numbers possible errors binary coded decimal (BCD) comparing BCD with."— Presentation transcript:

1 Extending Binary In today’s lesson we will look at: representing different types of numbers possible errors binary coded decimal (BCD) comparing BCD with pure binary

2 Binary So far we have looked at how to represent small positive integers – i.e. whole numbers – in binary. 1101 2814 x2 As we move left, the column headings increase by a factor of two In each column we can have two different digits (0 or 1) This number is: 8 + 4 + 1 = 13 It’s still thirteen, it’s just written down differently

3 Other Types of Numbers It’s unlikely that we’d only want to deal with small positive numbers. Computers can also cope with: –decimals and very small numbers –negative numbers –large numbers So how do they do it?

4 Decimals in Binary Binary can represent decimals in the same way as we represent decimals in denary. 0 101 2 8 14 x2 0 011 1/4 1/16 1/21/8 ÷2÷2 ÷2÷2 ÷2÷2 On the left we have 4 + 1 = 5 On the right we have ½ + ¼ = ¾ So, 0101.1101 in binary is 5 ¾ in denary!

5 Underflow Overflow is the name we give to the situation where a number is too big to fit into the allocated numbers of bits. It is also possible for a number to be too small to fit into the amount of space allocated – i.e. there are too many zeros after the decimal point but before the first digit. This is known as underflow.

6 Quantisation Error Another problem that can occur is called quantisation error. This is where the computer can’t accurately represent a value because it falls between two “steps”. When recording data such as sound waves, this can lead to distortion.

7 Floating Point Binary You might be familiar with standard (or scientific) form, e.g. 6 x 10 23. This is the binary equivalent: 0 1 0110 0 1 Mantissa: 1.0010 is 1 1/8Exponent: 2 5 = 32 1 1/8 x 32 = 36 Floating point representations are a way of increasing both range and precision.

8 Negative Numbers We’ve already seen that negative numbers in binary can be represented using a twos-complement. A ones-complement takes all of the digits and swaps 1s for 0s and vice versa – e.g. for the number 3: 00111100 A twos-complement just takes this number and adds one to it: 1101 This is -3 in twos- complement form

9 Negative Numbers Think about a car odometer going backwards: 0 0 01 2814 00 0 0 32 Sign 1664 0 0 0000 0 0 = 1 = 0 1 1 1111 1 1 = -1 1 1 1011 1 1 = -2 In this way, we can represent numbers from -127 to 127.

10 Binary-Coded Decimal All of our lessons on binary have looked at pure binary – working in base 2. There is also a system called binary- coded decimal. Rather than converting the whole number to binary, we convert it a digit at a time. The process is identical to hexadecimal conversion, except that values are less than ten (rather than less than sixteen).

11 Converting to BCD Converting to BCD is straightforward – just take each digit and convert it to four binary bits. 64 161 0 1 10 2814 0 1 00 2814 We then concatenate the results, so that 64 in decimal becomes 01100100 in binary.

12 Converting from BCD Changing back from BCD is the reverse process – split the bits into groups of four and convert: 97 1 0 01 2814 0 1 11 2814 We then concatenate the results, so that 10010111 in BCD is 97 in decimal.

13 Benefits of BCD? Some decimal values, such as 0.2, are non- terminating in binary (.001100110011...), which can lead to rounding errors, but can be represented exactly in BCD (0.0010). Scaling by a factor of 10 (or a power of 10) is simple; this can be useful when doing financial calculations – e.g. converting from pence to £s. Rounding to a fixed number of decimal places is easier. Displaying values is easier – e.g. displaying on a seven-segment display (like those used in digital clocks).

14 Disadvantages of BCD Some operations – e.g. adding - are more complex to implement. Adders for BCD require 15–20% more circuitry than those for pure binary. Standard BCD requires four bits per digit - roughly 20 percent more space than pure binary Systems using BCD are typically slower than those that use pure binary, due to limited processor support for native BCD operations.


Download ppt "Extending Binary In today’s lesson we will look at: representing different types of numbers possible errors binary coded decimal (BCD) comparing BCD with."

Similar presentations


Ads by Google