40 likes | 177 Views
Binary/decimal/ hexadecimal conversions. Decimal is base 10 and uses 10 digits (0,1,2,3,4,5,6,7,8,9). Topic 14.1 Extended Hexadecimal. Binary is base 2 and uses 2 digits (0,1). Computers also use octal (base 8 with the digits 0,1,2,3,4,5,6,7). IB doesn’t require you to know about octal.
E N D
Binary/decimal/hexadecimal conversions Decimal is base 10 and uses 10 digits (0,1,2,3,4,5,6,7,8,9). Topic 14.1 ExtendedHexadecimal Binary is base 2 and uses 2 digits (0,1). Computers also use octal (base 8 with the digits 0,1,2,3,4,5,6,7). IB doesn’t require you to know about octal. A more common numbering system in use by computers is the hexadecimal or base 16 numbering system. As computers grew in storage capacity, the bigger system became necessary. Since a base 16 numbering system needs more than the ten digits we are familiar with, we have to make up new characters for the additional six digits. Here is the whole set of digits (in order) for the hexadecimal numbering system: (0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F). FYI: IB expects you to convert between decimal and binary, and hexadecimal and binary. The next page will explain how conversions from (hex) to (bin) work, and it is really quite easy.
Binary/decimal/hexadecimal conversions We start by counting in binary to the decimal 15. Since we always start at zero, this will make 16 rows: Topic 14.1 ExtendedHexadecimal Note that we need four bits to represent all the decimals from 0 to 15. Each group of four bits represents a single hexadecimal digit. A third column is added using the hexadecimal digits: The shaded region represents the hexadecimal/binary conversion table. FYI: IB expects you to be able to make this conversion table from scratch. Be sure you understand how to do it!
Binary/decimal/hexadecimal conversions Here are some examples for the conversion from hexadecimal to binary: Topic 14.1 ExtendedHexadecimal The number D(hex) = 1101(bin) The number 2(hex) = 0010(bin) FYI: Be sure to always write hex to binary conversions as 4-bit strings (bunches). The number 2D(hex) = 00101101(bin) FYI: To convert hex to decimal, simply convert to binary, and then use the process you’ve already learned: 2D(hex) = 00101101(bin) = 32 + 8 + 4 + 1 = 45(dec) 2D(hex) = 45(dec)
Question: How many bits is contained in the number F129C0D(hex)? Answer: Each hex digit is four bits (binary digits) so that the total number of bits is 4 7 = 28 bits. Question: Many computers have “32-bit addresses” for memory location. How many hexadecimal digits are needed for addressing? Binary/decimal/hexadecimal conversions Here are some examples for the conversion from binary to hexadecimal: Answer: 32 / 4 = 8. Thus when you see an error message, you oftentimes also see a 32-bit location where the error appeared, in hexadecimal form: “Error occurred at FF0234C9,” for example. Topic 14.1 ExtendedHexadecimal The number 0011(bin) = 3(hex) Question: A byte is 8 bits. How many bytes are needed for addressing? The number 11(bin) = 3(hex) too. FYI: If your binary number doesn’t divide into groups of four, ADD LEADING ZEROS TO MAKE GROUPS OF FOUR. Answer: 32 / 8 = 4. You need 4 bytes for each address. The number 100011(bin) doesn’t break down into groups of four, unless we add two leading zeros: 100011(bin)=00100011(bin) = 23(hex) Convert 11110110101100011(bin) into hex: 1 1110 1101 0110 0011(bin) = 0001 1110 1101 0110 0011(bin) = 1 E D 6 3(hex) = 1ED63(hex)