131 Week 2 - Information Coding Flashcards
Why do we need information coding
To allow for more complex data and data types to exist but still be coded into (or represented as) something that is cheap and easy to store and process.
Computer hardware handles data types and data as small positive whole numbers.
ASCII
American Standard Code for Information Interchange
Defines 128 (2^7) symbols - 7 bit binary.
How can negative numbers be represented?
Sign and magnitude, excess n
Sign and magnitude
A character is used to represent if a number is negative or positive. It is then followed by the magnitude of the number.
It works however a column is sacrificed and 0 can be represented twice as it can be positive or negative.
Excess n
Uses n as a new value for 0. Any positive number is added to the n and any negative number is subtracted from the n.
e.g., 150 in excess 5000 is 5150. -25 in excess 5000 is 4975.
It doesn’t use an extra column and has a single value for 0.
How can decimal numbers be represented?
Fixed point, floating point
Fixed point decimals
Some columns are reserved for the fractional part of a number.
However this is not a very efficient use of columns.
Floating point decimals
Trades precision for range by using a mantissa and exponent to represent numbers. Mantissa and exponent are represented with sign and magnitude.
Mantissa * Radix^exponent
Radix
The amount of characters a number system uses to represent numbers.
Also called the base
Denary (decimal)
A way of representing numbers using 0-9
Radix (base) 10
Binary
A way of representing numbers using 0,1
Radix (base) 2
Octal
A way of representing numbers using 0-7
Radix (base) 8
Hexadecimal
A way of representing numbers using 0-9, A-F
Radix (base) 16
Addition rules for adding binary numbers
0+0=0
1+0=1
0+1=1
1+1=0 carry 1
1+1+1=1 carry 1
Problems with sign and magnitude and excess n arithmetic
Sign and magnitude: doesn’t deal with overflow
Excess n: x – y ≠ x + (-y)
Would need extra hardware to be able do subtraction as well as addition for excess n. This would be less space and cost effective.