# hex to binary conversion understanding

## Recommended Posts

a hex digit is represented by four bits . This hex number 235 has 3 digits . When converted to binary , it gives 1000110101 which are 10 bits

if a hex digit is represented by four bits so why I do not  get 12 bits as a result ?

##### Share on other sites

Because it omitted the leading zeros.

• 1

##### Share on other sites

hello thanks

but why it omitted the leading zeros

##### Share on other sites

That is how numbers are formatted, leading 0s will always be removed, unless you convert to text string.

• 1

##### Share on other sites

Leading zeros do not change the value of the number.  If you have 789 things, is 0000000000789 a different number?  No, it's not, the zeros do not change the number.  The hex value would be 0010 0011 0101, those are the three bytes, but if you put those together then you don't need the leading zeros.

Also, this only matters if you are treating this as an actual number.  Maybe those 2 leading zeros are part of the binary data, which means you would not remove them.  If you're going to convert it to a number though, then you don't need leading zeros.

• 1

## Create an account

Register a new account