Notes on correct solutions fro h6 (after it was graded). ** #1 Bases ** Converting from base 2, 8, 16 to base 10 - All are basically the same - Rightmost digit is the 1's digit - Next rightmost is worth "base" - Next rightmost after that is worth base**2 - Then base**3 - Etc. - In bases higher than 10, we need a digit for 10, 11, 12, .... We use a=10, b=11, c=12, d=13, e=14, f=15 Examples: 2865 5 is the 1's digit, 6 10's digit, 8 10**2's, 2 10**3's 5*1 + 6*10 + 8*10**2 + 2*10**3 2*10**3 + 8*10**2 + 6*10 + 5*1 Example: 101110b 101110b 0 is the 1's digit, 1 is 2's digit, 1 is the 2**2's digit, 1 is the 2**3's digit, 0 is the 2**4's digit, 1 is the 2**5's digit 1*2**5 + 0*2**4 + 1*2**3 + 1*2**2 + 1*2 + 0*1 = 46 Example: 524 base 6 4 is the 1's digit, 2 is 6's digit, 5 is the 6**2's digit 5*6**2 + 2*6 + 4*1 Converting from base 10 to base 2, 8, 16 - All are basically the same - Two methods a) write out powers of base b) divide by base, take remainder, repeat - note that this gives the digits in reverse order Example: 76 decimal, convert to binary a) write out powers 1, 2, 4, 8, 16, 32, 64, 128 76 = 64 + 12 12 = 8 + 4 76 = 64 + 8 + 4 = 1*64 + 0*32 + 0*16 + 1*8 + 1*4 + 0*2 + 0*1 = 1001100b But if we convert 76 to base 6 1, 6, 36, 216 76/36 = 2 remainder 4 76 = 2*36 + 4 = 2*36 + 0*6 + 4*1 = 204 base 6 b) divide by base... 76//2 = 38 remainder 0 38//2 = 19 remainder 0 19//2 = 9 remainder 1 9//2 = 4 remainder 1 4//2 = 2 remainder 0 2//2 = 1 remainder 0 1//2 = 0 remainder 1 76 = 1001100b Convert 76 to base 6 76//6 = 12 remainder 4 12//6 = 2 remainder 0 2//6 = 0 remainder 2 76 = 204 base 6 Converting between base 2 and base 16 is really easy - 4 bits of binary corresponds to 1 hexadecimal digit (16 = 2**4) - pad binary with 0's so each hex digit is exactly 4 bits Example: convert 1110101110101b to base 16 0001 1101 0111 0101b 1 14 7 5 hex 1 E 7 5 hex 1E75 Example: convert 4bf20 hex to binary 4 b f 2 0 hex 0100 1011 1111 0010 0000b Largest number in base 2, 8, 10, 16 with X digits - Largest digit in that base repeated X times ** #2 Files and file extensions ** "Magic code" - Not all file types have something like this - Those that do have some specific bytes that are always at a set position in the file - For many of these, it will be the first bytes in the file - Some "magic codes" are characters so that you could see them by opening the file in a text editor (e.g., open something.pdf in Notepad or TextEdit) - Others are not, so you have to say what the bits are, or equivalently what the bytes are in hexadecimal - Some file types have slightly different magic codes depending on the version of the file ** #3 Computer Components ** RAM, CPU, Storage - Three main parts of the computer - Note that the CPU has a few different types of "memory" internal to itself + CPU registers re the fastest of all, and also the fewest - just a few KB of registers + CPU cache is fast memory on the CPU and is broken into levels - L1 is faster than L2 is faster than L3 (and L1 is smaller than L2 is smaller than L3) - Speed: CPU > RAM > Storage - Cost per byte: CPU > RAM > Storage - Size: CPU < RAM < Storage - Speed of CPU is in GHz - Speed of RAM is in GHz - Speed of Storage is often given in MB/s or GB/s