Tips and Tricks: Converting numbers between bases faster
If you find the methods of conversion traditionally taught at school boring and slow, you are not the only one. From Binary to Decimal Tip 1: Double dabble Consider the integer D n D n-1 ...D 1 D 0 with (n+1) digits. Starting with the most significant bit, carry out the following algorithm: Result = D n Result = Result * 2 Result = Result + D n-1 Repeat steps 2 and 3 until you have added the least significant bit to Result D 0 to Result For example, the number 10100101 2 = 165 10 Result = 1 Result = Result * 2 = 2 Result = Result + 0 = 2 Result = Result * 2 = 4 Result = Result + 1 = 5 Result = Result * 2 = 10 Result = Result + 0 = 10 Result = Result * 2 = 20 Result = Result + 0 = 20 Result = Result * 2 = 40 Result = Result + 1 = 41 Result = Result * 2 = 82 Result = Resu...