Hexadecimal: Uses

Why use hexadecimal? • You can represent 16 bit words as only 4 hexadecimal digits –less display space is needed and it is faster to enter the data • It is easy to convert hex digits back to binary if necessary • It is EASIER to identify values, and it is EASIER to spot errors in hexadecimal, rather than if working with long binary strings. Hex in colour coding To recap, colours are often represented in hexadecimal when formatting web pages in either HTML or CSS. The # indicates that a colour is being coded in. E.g. text goes here Two hexadecimal digits for each of the colours red, green and blue. EG: FFFFFF = white, FF0000 = red , 000000 = black 1. The value of the hexadecimal numbers represents a colour’s intensity, allowing the full spectrum to be coded. 2. You will also see hex options in graphics packages such as Adobe Creative Suite apps, when setting colour values. 3. Laser cutters often use colour codes to identify how to set the laser strength and depth of cut. In the cutters at SPGS, we use red (#ff0000) to cut and black (#000000) to engrave. Hex in low level programming You also met the use of hexadecimal in assembly code, when looking at high level and low level languages. Low level coding (assembly and machine code) references memory directly. Hexadecimal is used in low level coding because it is quicker, easier and less error prone for programmers to type assembly code values in hex, than to type in long binary strings. E.g. STO FFA4 is an assembly code to carry out a store operation at a hexadecimal address. A5E4 FFA4 (equivalent code using only hexadecimal digits) 1010 0101 1110 0100 1111 1111 1010 0100 (equivalent machine code using binary) Hexadecimal also makes it more efficient to troubleshoot low level code. Hex in addresses Hex is used in addressing - both for knowing where something is, that is on a network (IP address), and what that thing actually is (MAC address). Media access control addresses (MAC addresses) are used to uniquely identify devices on a network. MAC addresses are assigned by the device manufacturer. MAC addresses are made of six pairs of hexadecimal digits. NN—NN—NN—DD—DD—DD NN—NN—NN = I.D. of manufacturer DD—DD—DD = serial number of the device Internet Protocol addresses (IP addresses) are used to identify where a device is on a network. IP addresses can be IP version 4, which uses decimal numbering, or IP version 6, which uses hex. IPv6 provides enough unique addresses for every networked device on the planet. IPv6 uses a 128 bit address. Digits are organised into eight groups. Each group is made up of four hexadecimal digits. Hex in error messaging One more use of hexadecimal numbers is in the display of error codes in embedded systems, such as lifts. Embedded systems often have tiny screens, if they have any at all. Hex codes take up less screen space than long binary strings. If any of your machines at home come up with error codes when they go wrong, type them into the internet to see if there is an easy fix that you can carry out to get your machine or device going again!You can represent 16 bit words as only 4 hexadecimal digits –less display space is needed and it is faster to enter the data • It is easy to convert hex digits back to binary if necessary • It is EASIER to identify values, and it is EASIER to spot errors in hexadecimal, rather than if working with long binary strings. Hex in colour coding To recap, colours are often represented in hexadecimal when formatting web pages in either HTML or CSS. The # indicates that a colour is being coded in. E.g. text goes here Two hexadecimal digits for each of the colours red, green and blue. EG: FFFFFF = white, FF0000 = red , 000000 = black 1. The value of the hexadecimal numbers represents a colour’s intensity, allowing the full spectrum to be coded. 2. You will also see hex options in graphics packages such as Adobe Creative Suite apps, when setting colour values. 3. Laser cutters often use colour codes to identify how to set the laser strength and depth of cut. In the cutters at SPGS, we use red (#ff0000) to cut and black (#000000) to engrave. Hex in low level programming You also met the use of hexadecimal in assembly code, when looking at high level and low level languages. Low level coding (assembly and machine code) references memory directly. Hexadecimal is used in low level coding because it is quicker, easier and less error prone for programmers to type assembly code values in hex, than to type in long binary strings. E.g. STO FFA4 is an assembly code to carry out a store operation at a hexadecimal address. A5E4 FFA4 (equivalent code using only hexadecimal digits) 1010 0101 1110 0100 1111 1111 1010 0100 (equivalent machine code using binary) Hexadecimal also makes it more efficient to troubleshoot low level code. Hex in addresses Hex is used in addressing - both for knowing where something is, that is on a network (IP address), and what that thing actually is (MAC address). Media access control addresses (MAC addresses) are used to uniquely identify devices on a network. MAC addresses are assigned by the device manufacturer. MAC addresses are made of six pairs of hexadecimal digits. NN—NN—NN—DD—DD—DD NN—NN—NN = I.D. of manufacturer DD—DD—DD = serial number of the device Internet Protocol addresses (IP addresses) are used to identify where a device is on a network. IP addresses can be IP version 4, which uses decimal numbering, or IP version 6, which uses hex. IPv6 provides enough unique addresses for every networked device on the planet. IPv6 uses a 128 bit address. Digits are organised into eight groups. Each group is made up of four hexadecimal digits. Hex in error messaging One more use of hexadecimal numbers is in the display of error codes in embedded systems, such as lifts. Embedded systems often have tiny screens, if they have any at all. Hex codes take up less screen space than long binary strings. If any of your machines at home come up with error codes when they go wrong, type them into the internet to see if there is an easy fix that you can carry out to get your machine or device going again!

robot