How to enumerate the position of a bit within a byte?

Asked

Viewed 289 times

1

Where to start placing an ordinal numbering on a given byte, I start counting the most significant (the left )or the least significant (the right)?

For example for the decimal number 128 having the represntation in binary:

1000 0000

If I want to refer to eighth byte bit, who is the digit in question?
1 or 0 ?

It would be mode A or mode B?
Mode A
1000 0000
8765 4321

Mode B
1000 0000
1234 5678

  • I’m not sure I understand what you want, if it’s something conceptual, if it’s concrete. Concretely it’s much more complicated than that. I do not know if the question is not wide. Enumerate how? by the question I can only assume that is look there and count to 8 and get the desired digit.

1 answer

1


The way To would be right.

Ignore the name bit - A binary value is represented in the same way as a decimal value: In an integer the highest value positions are located on the left, since new positions are added when the previous position suffers overflow:

    8 + 1  // 9:     Uma casa decimal
    9 + 1  // 10:    Não pode ser contido em apenas uma posição,
   10      //        casa decimal 2 recebe o valor em overflow.
  ...
   98 + 1  // 99:    Duas casas decimais
   99 + 1  // 100:   Não pode ser contido em apenas duas posições, 
  100      //        casa decimal 3 recebe o valor em overflow.

Thus:

128 = 100 + 20 + 8

In the above example we can say the position(house) 3 holds the value 1, which means 100 decimally.

In binary the value

1000 0000

Holds the value 1 in position 8, which also means 128 (2 to 7 power).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.