The number 251 can be represented in binary using the following method:
Add a 1 to any columns, that when added together, make up the decimal number.
128 + 64 + 32 + 16 + 8 + 2 + 1 = 251
The binary number 1101 0111 can be represented in denary using the following method:
Write the binary number under the column headings and add together any columns which have a 1 stored in them.
128 + 64 + 16 + 4 + 2 + 1 = 215
To convert a negative denary number to a two's complement binary value:
Find the binary value of the number as a positive
Change all the 1s to 0s, and all the 0s to 1s
Add 1
For Example, converting -113 to binary
The two's complement representation of -113 as an 8-bit binary numbers is 1000 1111.
To convert a two's complement binary number to denary:
Change all the 1s to 0s, and all the 0s to 1s
Add 1
Convert to denary
Determine the sign by looking at the original binary number
(if the left-most bit is a 1, the number is negative)
Here is the example 1000 1111.
Treat the leftmost bit as a negative (-128), then add any remaining columns which have a 1.
-128 + 8 + 4 + 2 + 1 = -113
If a computer stores a positive number, it has a range of numbers it can represent.
The formula to calculate the range is:
0 to (2^n)-1 where n is the number of bits
Range of positive Integers for 16 bit binary: 0 to 65535
When using the two's complement to store a negative number, the range of numbers is different to include the negative values.
The formula to calculate the range for these is:
The biggest negative value:
-2n-1
The biggest positive value:
(2n-1) - 1
where n is the number of bits
Range of positive and negative integers with 16 bit binary: -32767 to +32768
Real numbers, also called floating point numbers, are numbers that include a fraction after the decimal point.
e.g. 99.9, -32.123 etc.
A computer stores these using a mantissa and exponent.
In denary, the real number 6890.1363 could be stored as 0.68901363 x 10^4
The mantissa is the significant number and the exponent is how many times the decimal point moved.
As humans, we are taught to represent denary numbers such as 99.75 as:
A computer would represent the same number in binary as:
Take the fixed point binary number: 1110.0101
Represented using floating-point: 11100101 x2^100
The mantissa is 11100101 and the exponent is 100.
Floating point number are represented using 8 bits for the exponent and 16 bits for the mantissa, including a sign bit. The sign bit is represented in binary as 0 for positive and 1 for negative.
If the decimal point moves to the left, the exponent is positive.
If the decimal point moves to the right, the exponent is negative (represent using two's complement).
Add additional bits to the right of the mantissa to make it up to 15 bits.
Add addition bits to the left of the exponent to make it up to 8 bits.
As can be seen from the example earlier the more bytes that we have for the mantissa means we can represent decimal fractions more accurately.
Whereas the number of bytes used for the exponent means we can move the decimal point more places which means we can represent a larger range of numbers.
Characters (numbers, letters, symbols, control/non-printable) can be represented using 8-bit ASCII.
However, ASCII is limited because it can only represent 255 characters and it can’t store characters such as non-Latin / non-Roman alphabets (Greek, Arabic, Chinese etc.), symbols or emoji's. If we look at the Chinese language there are over 3,500 commonly used characters. None of which are represented by the ASCII code.
To overcome this limitation the Unicode method of representation is used.
Unicode is an alternate method of representing text. Unicode uses 16 bits per character. This means that there is a maximum of 65,536 characters that can be represented using this notation. ASCII still forms the basis for this with the first 128 characters being common to the ASCII and Unicode character sets.
✓ Uses less storage space per character
✘ Can represent less symbols
✓ Can represent more symbols.
✓ Can represent more languages.
✘ Uses more storage space per character
We learned about these two ways of storing images in N5. For a recap click the button below.
Advantages
✓ can produce realistic photographic images
✓ control over pixel-level editing
Disadvantages
✘ resolution is set at point of creation and cannot be increased without a loss of quality (resolution dependent)
✘ tends to have a larger file size than a vector graphics file
Advantages
✓ can be scaled without a loss in quality (resolution independent)
✓ can make best use of high-resolution output devices
✓ vector objects can be edited independently of each other
✓ vector objects can be easily moved / manipulated
✓ tends to have a smaller file size than a bit-mapped graphics file
Disadvantages
✘ no control over pixel-level editing
✘ unsuitable for photo-realistic images