Base 10 to Base 2

Thread Starter

David Waddell

Joined Dec 3, 2014
24
I have an assignment which asks me to convert a denary number to 8 bit binary. The first number I have been given is 42.

42(BASE10) = 101010(BASE2)

I don't know if I'm being stupid or not. My answer only has 6 numbers, does an 8 bit binary have to have 8 numbers? Any clarification would be great.
 

WBahn

Joined Mar 31, 2012
30,086
I have an assignment which asks me to convert a denary number to 8 bit binary. The first number I have been given is 42.

42(BASE10) = 101010(BASE2)

I don't know if I'm being stupid or not. My answer only has 6 numbers, does an 8 bit binary have to have 8 numbers? Any clarification would be great.
If you were asked to write 42 as a six-digit decimal integer you would write it as 000042, right?
 

crutschow

Joined Mar 14, 2008
34,470
The number of bits indicates the maximum number that can be represented (for 8-bits it would be 255d), not that every number has to have 8-bits.
 
8 bits can also represent 0-255, -128 to +127 or +-127 depending on the representation.

So, if you were asked to convert -42d into 8 bit binary, would you flinch? There could be two answers. What did teach say 8 bit binary is?

This is where I might win with lots of answers.
 

MrAl

Joined Jun 17, 2014
11,496
Hi,

A number like 1010 would simply be written as 00001010 to show all 8 bits.
So fill the missing leading digits with zeros because those bits have to be zero.
 
Top