How to Convert Decimal to Binary: Two Easy Methods, Worked Examples and Code
To convert a decimal number to binary, divide it by 2 repeatedly and write down each remainder, then read the remainders from bottom to top. For example, 13 ÷ 2 gives remainders 1, 0, 1, 1, so 13 in binary is 1101.