Binary conversion?

Hey guys can I get some help on how to convert base 10 to base 2?

I'm trying to convert 2016(base10) into ?(base2)

I'm not sure what to do help? Can someone teach me a really good method?
The usual method is to find the largest power of two which can be subtracted from tne number without producing a negative. You then subtract that power of two and write a 1 to the left hand side of your answer. You then loop through all the powers of two from the one you just subtracted, all the way to 2^0. Each time, if the power of two is greater than the number, write a zero on the right hand side of your answer, if it isn't, subtract the power of two from the number and write a 1. If you want a fixed length binary number, start with 2^number of digits-1.
eg 114 to an 8 bit binary number:
128 > 114 --------------------->0
64 < 114 114 - 64 = 50 ----->1
32 < 50 50 - 32 = 18 -------->1
16 < 18 18 - 16 = 2 ---------->1
8 > 2 ---------------------------->0
4 > 2 ---------------------------->0
2 = 2 2 - 2 = 0 ----------------->1
1 > 0 ---------------------------->0

Hence 114 converts to 01110010. You can remove the leading zeros and start with 64 rather than 128 if the length of binary number is not specified.
Last edited on
Topic archived. No new replies allowed.