Bifalgorithm post · Brisk · Chapter 1

How do you convert between binary and decimal?

How do you convert between binary and decimal? (Brisk · Chapter 1) — "Converting from binary to decimal was demonstrated above, with 110101₂ = 53₁₀. To go the…

Ideas in this flowchart

  • Umwandlung von Dezimalzahlen in Binärzahlen
  • Die Umwandlung von Binärzahlen in Dezimalzahlen wurde zuvor mit 110101₂ = 53₁₀ demonstriert.
  • Für die Umwandlung in die andere Richtung wird ein Algorithmus verwendet.
  • Beispiel: Umwandlung der Dezimalzahl 49.
  • Berechne den Rest bei Division durch 2, indem geprüft wird, ob die Zahl gerade oder ungerade ist.
  • Teile die Zahl durch 2 und bilde das Abrundungsergebnis.
  • Wenn der Quotient nicht null ist, wird der neue Wert übernommen und der Vorgang wiederholt.
  • 49 ist ungerade; daher ergibt 49 mod 2 den Rest 1.
  • ⌊49 ÷ 2⌋ = 24.
  • Da 24 nicht null ist, wird 24 zum neuen Wert.
  • 24 ist gerade; daher ergibt 24 mod 2 den Rest 0, der links von der 1 notiert wird.
Feed/

How do you convert between binary and decimal?

Channel

Brisk

1 page

"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:"

Flowchart preview
Series cover
👍
0
0 comments0 shares

Sign in to view and post comments.