• We are familiar with numbers based on units of 10, a result of our 10 fingers. But, other number bases are possible.
• When using digital systems, we will use a variety of numbering systems (other than in units of 10).
• With computers, number bases that are multiples of 2 are favored.
base 2: binary
base 8: octal
base 16: hexadecimal
• For each base we count as usual, but the numbers stop at some value, then a more significant digit is added.
18.1 Data Values
• Binary is best used in computers because signals are ON/OFF which is well suited to the two binary digits.
• Converting between number systems can be done by looking at digit magnitude.
• Conversion can also be done between systems by division.
• For division use remainders.
• Convert the following numbers to/from binary
• Binary bytes and words are shown below.
18.1.2 Boolean Operations
• In most discrete systems the inputs and outputs (I/O) are either on or off. This is a binary state that will be represented with,
1 = on
0 = off
• Because there are many inputs and outputs, these can be grouped (for convenience) into binary numbers.
• Consider an application of binary numbers. There are three motors M1, M2 and M3
100 = Motor 1 is the only one on
111 = All three motors are on
in total there are 2n or 23 possible combinations of motors on.
• The most common Binary operations are,
18.1.3 Binary Mathematics
• These include standard logic forms such as,
• Negative numbers are a particular problem with binary numbers. As a result there are two common numbering systems use,
signed binary: the most significant bit (MSB) of the binary number is used to indicate positive/negative
2s compliment: negative numbers are represented by complimenting the binary number and then adding 1.
• Signed binary numbers are easy to understand, but much harder to work with when doing calculations.
• An example of 2s compliments are given below,
• When adding 2s compliment numbers, additional operations are not needed to deal with negative numbers. Consider the examples below,
18.1.4 BCD (Binary Coded Decimal)
• Each digit is encoded in 4 bits
• This numbering system makes poor use of the digits, but is easier to convert to/from base 10 numbers. For the two bytes above the maximum numbers possible are from 0-9999 in BCD, but 0-64285 in binary.
• Convert the BCD number below to a decimal number,
• Convert the following binary number to a BCD number,
18.1.5 Number Conversions
• Convert the following binary number to a Hexadecimal value,
• Convert the following binary number to a octal,
18.1.6 ASCII (American Standard Code for Information Interchange)
• While numbers are well suited binary, characters don’t naturally correspond to numbers. To overcome this a standard set of characters and controls were assigned to numbers. As a result, the letter ‘A’ is readily recognized by most computers world-wide when they see the number 65.
18.2 Data Characterization
• Parity: used to detect errors in data. A parity bit can be added to the data. For example older IBM PCs store data as bytes, with an extra bit for parity. This allows real-time error checking of memory.
• Parity can be even or odd.
• The odd parity bit is true if there are an odd number of bits on in a binary number. On the other hand the Even parity is set if there are an even number of true bits.
• Convert the decimal value below to a binary byte, and then determine the odd parity bit,
18.2.2 Gray Code
• A scheme to send binary numbers, but encoded to be noise resistant.
• The concept is that as the binary number counts up or down, only one bit changes at a time. Thus making it easier to detect erroneous bit changes.
ASIDE: When the signal level in a wire rises or drops, it induces a magnetic pulse that excites a signal in other nearby lines. This phenomenon is known as ‘cross-talk’. This signal is often too small to be noticed, but several simultaneous changes, coupled with background noise could result in erroneous values.
• Parity bits work well when checking a small number of bits, but when the sequence becomes longer a checksum will help detect transmission errors.
• Basically this is a sum of values.
Problem 18.1 a) Represent the following decimal value thumb wheel input as a Binary Coded Decimal (BCD) and a Hexadecimal Value (without using a calculator).
b) What is the corresponding decimal value of the following BCD
Answer 18.1 a). 3532 = 0011 0101 0011 0010 = DCC, b). the number is not a valid BCD
Problem 18.2 TRUE or FALSE -- A Word is 3 nibbles.
Answer 18.2 false
Problem 18.3 Convert the following from binary to decimal, hexadecimal, BCD and octal.
Problem 18.4 Convert the following from decimal to binary, hexadecimal, BCD and octal.
Problem 18.5 Convert the following from hexadecimal to binary, decimal, BCD and octal.
Problem 18.6 Convert the following from BCD to binary, decimal, hexadecimal and octal.
Problem 18.7 Convert the following from octal to binary, decimal, hexadecimal and BCD.
Problem 18.8 Why are binary, octal and hexadecimal used for computer applications?
Problem 18.9 Add/subtract/multiply/divide the following numbers.
Problem 18.10 What are the specific purpose for Gray code and parity?
Answer 18.10 Both of these are coding schemes designed to increase immunity to noise. A parity bit can be used to check for a changed bit in a byte. Gray code can be used to check for a value error in a stream of continuous values.