ITP 165x Lecture Notes - Lecture 24: Binary Number
Document Summary
Itp 165: intro to c++ - lecture 24: binary refresher. In decimal (base 10), every digit can range from 0 to 9. So 150 in decimal is equal to the value of 100 + 50 + 0 = 150 in decimal. This means that every digit can only be a 1 or a 0. So 101 in binary is 4 + 0 + 1 = 5 in decimal. Internally, computers use binary to represent all of their numbers. In order to easily convert from decimal to binary, you need to know the powers of 2. Hexadecimal (or hex) is base 16, so the digits range from 0 to f. The easy way is to break the binary number into groups of 4. So for example, 45 written in binary is 00101101. Treat each group of 4 bits as a separate 4-bit binary number, and convert each group of. Finally, convert each decimal number to the corresponding hex digit.