THE SOFTWARE DEVELOPER’S VIEW OF THE HARDWARE

Representation of data within the computer

All data within is stored and processed as Binary

Base 2 Number system only TWO characters are allowed 0 or 1

Two state system is ideal for a variety of storage/processing methods e.g.

–CDROMs Lands or pits

–Barcodesblack or white lines

–Paper tape holes or no holes

–Cardspencil mark or no pencil mark

•Binary to decimal conversion

1101112 =1x26 +1x25 +0x 24 +1x23+ 1x22+ 1x21

= 32 +16 + 0 + 4 + 2 + 1

= 5510

•Hexadecimal to decimal conversion

5C316= (5 x 162) + (C x 161) + (3 x 160)

= (5 x 256) + (12 x 16) + (3 x 1)

= 1280 + 192 + 3

= 147510

character representation, namely:

  • ASCII (American Standard Code for Information Interchange) allows text data to be stored in binary form using 7 bits to encode a total of 128 characters. The “spare” bit is known as a parity bit when used for error-checking. Sorting ASCII in ascending order places uppercase letters before lowercase.
  • BCD (Binary Encoded Decimal) stores each digit using 4 bits. It is not sufficient for alphabet characters, as it can only represent 16 (24) characters, ten of which are decimals.
  • EBCDIC (Extended Binary Coded Decimal Interchange) uses 8 bits and thus 256 characters can be encoded.
  • Hexadecimal numbers are to the base 16, of values 0-9 and then A-F.

integer representation, including:

  • Sign and modulus uses the leftmost bit to represent the sign of a number. 0 is positive, while 1 is negative. The remaining bits give the magnitude or modulus of the number. There are two representations of zero using this method, positive 00000000 and negative 10000000.
  • Using one’s complement, all the zeros and ones in the positive form are reversed to represent its negative form, and thus the range extends from –128 to +127 (where 0 is positive) using an 8 bit system. There are two representations of zero using this method, positive 00000000 and negative 11111111.
  • Two’s complement can be found by adding 00000001 to the one’s complement of a number. There is only one representation of zero using this method, 00000000, as 11111111 + 1 is not allowable.

11011011 -> 00100100 (flip digits) -> 00100100 + 1 -> 00100101 (Two’s Complement)

representation of fractions, namely floating point or real

  • Floating point or real numbers are a method of representing fractions. They are made up of a sign bit, an exponent (8 bits), and a mantissa (23 bits). IEEE 754 floating point standard is used in most computers.
  • Real numbers allow for a grater range of numbers to be represented, because they are able to take into account both positive and negative numbers. However, large numbers, or those with a large number of decimal places, may not be completely accurate because there is only a finite amount of space to store the number.
  • Problems with inaccuracy often as many decimal fractions cannot be represented as exact binary fractions. When the number of digits exceeds the space allocated for storage, it must be truncated, not rounded, to avoid and overflow error.

binary arithmetic, including:

  • All binary arithmetic operations can be reduced to addition
  • Addition is the basis of all arithmetic operations inside the computer. The rules for binary addition are 0 + 0 = 0, 1 + 0 = 1, and 1 + 1 = 0 (where the 1 carries into the next position). If the number is outside the bit range, and overflow error results.
  • Subtraction is performed through complementary addition. Computers cannot carry out direct binary subtraction as they do not understand the concept of borrowing digits. Subtracting the number is the same as adding the negative value of the number (i.e. A + [-B]). Therefore the two’s complement of the number to be subtracted is taken and added to the other number.
  • Multiplication is carried out in the exact same way as long hand multiplication.
  • Division can be carried out using long division, using the shift and subtract technique.

Multiplication

7 x 5 = 35
or
111 x 101 = / 111 x
101
111
0000
11100
100011 / 100011 binary =
1 x 32 + 0 x 16 + 0 x 8 + 0 x 4 + 1 x 2 + 1 x 1 =
32 + 0 + 0 + 0 + 2+ 1 = 35

HSC Past Paper Questions :

1. The keyboard character ‘h’ has the ASCII code number which is represented in

binary as 1101000.

(i) Convert this to its decimal equivalent. Show all working.

(ii) The decimal representation of keyboard character ‘H’ has a value that is 32

less than ‘h’. Calculate the binary value of its ASCII code number. Show

all working.

2. Explain the difference between the one’s and two’s complement methods for

representing a negative number in binary using 4-bit representation.

3. (i) Explain how a fraction is represented in single precision floating point

binary representation.

(ii) Convert the decimal number 45 (ie 4510) to a hexadecimal number.

(iii) Using four-bit binary representation and two’s complement, perform the

following subtraction: 1110–0111.

4. Describe the differences between integer representation and floating point

representation of numbers. Give an example where each would be appropriate.

5. Compare and contrast character representation in ASCII and hexadecimal.

Syllabus Covered by these notes

Students learn about: / Students learn to:
Representation of data within the computer
•character representation, namely:
–ASCII
–hexadecimal
•integer representation, including:
–sign and modulus
–one’s complement
–two’s complement
•representation of fractions, namely:
–floating point or real
•binary arithmetic, including:
–addition
–subtraction using two’s complement representation
–multiplication, shift and add
–division, shift and subtract / •convert integers between binary and decimal representation
•interpret the binary representation of data
•recognise situations in which data can be misinterpreted by the software
•perform arithmetic operations in binary