Concept

How do you convert between binary and decimal?

Stephen Davies, Ph.D. Version 2.2.2 Through Discrete Mathematics A Cool Brisk Walk / Chapter 1

"Converting from binary to decimal was demonstrated above, with 110101₂ = 53₁₀. To go the other way, we follow the algorithm from page 170. Let’s try it for the decimal number 49: 1. (Step 1) We first compute 49 mod 2. Doing “mod 2” is easy: you just see whether the number is even or odd. In this case, it’s odd, so the remainder is a 1. 2. (Step 2) Now divide 49 by 2 and take the floor, which gives ⌊49 ÷ 2⌋ = 24. It’s not zero, so we perform step 2b: make 24 our new value, move our pencil to the left of the 1, and go back to step 1. 3. (Step 1) Compute 24 mod 2. Since 24 is even, this is zero, which we write down to the left of the 1:"

Related Ideas

How do you convert between binary and decimal? | Stephen Davies, Ph.D. Version 2.2.2 Through Discrete Mathematics A Cool Brisk Walk | Bifalgorithm | Bifalgorithm