Skip to content · ⁨דלג לתוכן⁩

Denary to binary · ⁨מספר עשרוני למערכת בינארית⁩

English

Denary to binary

Go the other way: from a denary number to its binary digits.

Divide by 2 again and again. The remainder n % 2 is the next bit, and n // 2 is what is left to convert. The remainders come out right to left, so put each new bit at the front of the string. 0 needs its own answer, because the loop would never run.

עברית

מערכת עשרונית לבינארית

לך בכיוון ההפוך: ממספר עשרוני לספרות הבינאריות שלו.

חלק פי 2 שוב ושוב. שארית n % 2 היא הביט הבא, וn // 2 הוא מה שנותר להמרה. השאריות יוצאות מימין לשמאל, אז הצמד כל ביט חדש בפני המחרוזת. 0 זקוק לתשובה משלו, כי הלולאה לעולם לא תתנהל.

Log in or create account · ⁨היכנס או צור חשבון⁩

IGCSE, A-Level & AP