Two other forms of number representation can be used to represent integers. They
are Octal and Hexadecimal (Hex for short) systems. The first has a base of 8, the second a base
of 16. Click Octal number representation to learn about the Octal system. Hexadecimal Hexadecimal is 16 based and uses the digits 0 to 9 and the letters a to f to represent the values 0 to 15. Letters are used after values past nine as two digits can not be used. Hexadecimal is used more often than octal as any four bits of a binary number can be converted into its hexadecimal equivalent and vice-versa. The number 345 in hexadecimal is 837 as a decimal.
Another example using 2 bits is d9, which is 217 in decimal (Note: d in hexadecimal = 13 in decimal)
An eight bit binary number can be converted into its hexadecimal equivalent easily. For example, convert 11111111 into hexadecimal. (The answer is ff).
Computer monitors use a red, green and blue colour system.This is also know as RGB for short. Each pixel on the screen is a combination of different strengths of each of the three colours. In a 24 bit colour system a byte, 8 bits (24/3 = 8), is used for each colour. The maximum value a byte can hold id 28 - 1 = 255 (take 1 away to allow for zero). A value of 255, or ff in hex, means the colour is used at its full strength. A value of 0, or 00 in hex, means none of the colour is used in the overall mix of colours. Note: upper or lower case letters can be used when writing hex, so ff is equivalent to FF. In HTML red, green and blue colour values are often expressed in hexadecimal. There are six hex numbers in a colour; two for each colour. Reading from the left the first two represent the strength/amount of red in the colour, the next two the strength of the green and the last two the strength of the blue. For example, to set the background colour of a web page to black the following cascading style sheet (CSS) code could be used. Note: the # sign signifies to the web browser that the number is a hexadecimal value. body{ background-color:#000000;
}
black colour
In other words no red, green or blue is used, hence the page is black. If we wanted a full strength red the code would be, body{ background-color:#ff0000;
}
red colour
If we wanted magenta we would use,
body{ background-color:#ff00ff;
}
magenta colour
That is full strength red and blue, and no green. 2563 or 16,777,216 (ffffff in hex) different colour combinations can be made, because there can be 256 shades of each of the three colours. This is known as a 24 bit colour system as 256 in decimal is the maximum value eight bits can represent in binary, and 3 (the number of colours) x 8 = 24. Additional resources
|