Convert from Decimal to Binary
The convertion from decimal to binary can be achived through recursivly dividing the decimal value through 2. Then the integer result of each devision is written down from left to right and the reminder is divided again through 2 until the reminder is zero.
Example: 77 => binary
77 / 2^7 = 77 / 128 = 0 (first bin digit)
77 % 2^7 = 77
77 / 2^6 = 77 / 64 = 1 (second bin digit)
77 % 2^6 = 13
13 / 2^5 = 13 / 32 = 0
13 % 2^5 = 13
13 / 2^4 = 13 / 16 = 0
13 % 2^4 = 13
13 / 2^3 = 13 / 8 = 1
13 % 2^3 = 5
5 / 2^2 = 5 / 4 = 1
5 % 2^2 = 1
1 / 2^1 = 1 / 2 = 0
1 % 2^1 = 1
1 / 2^0 = 1 / 1 = 1
1 % 2^0 = 0
=> 0b01001101 (= 77)