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.

한국어

진법수를 이진수로 변환

반대로 진행하십시오: 진법수에서 이진수 digit들까지.

2으로 계속 나누십시오. 나머지 n % 2이 다음 비트가 되고, n // 2는 아직 변환하지 않은 나머지 값입니다. 나머지는 오른쪽에서 왼쪽으로 나오므로, 새로운 비트마다 문자열 맨 앞에 추가하십시오. 0은 자체 답안이 필요하며, 루프가 실행되지 않기 때문입니다.

Log in or create account · ⁨로그인 또는 계정 만들기⁩

IGCSE, A-Level & AP