hisoka Posted June 21, 2018 Share Posted June 21, 2018 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 ? Link to comment Share on other sites More sharing options...
davej Posted June 21, 2018 Share Posted June 21, 2018 Because it omitted the leading zeros. 1 Link to comment Share on other sites More sharing options...
hisoka Posted June 21, 2018 Author Share Posted June 21, 2018 hello thanks but why it omitted the leading zeros Link to comment Share on other sites More sharing options...
dsonesuk Posted June 21, 2018 Share Posted June 21, 2018 That is how numbers are formatted, leading 0s will always be removed, unless you convert to text string. 1 Link to comment Share on other sites More sharing options...
justsomeguy Posted June 21, 2018 Share Posted June 21, 2018 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 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now