-1

I have a question. How do I convert 100000000(as a 8 bit number) to decimal . Thanks for helping

  • Ah Thanks.It’s not coding – Myllene Muamba Sep 15 '19 at 20:10
  • Just multiply every bit by 1, 2, 4, 8, 16, 32, ... from right to left. For example, `1010` is `8 + 0 + 2 + 0` and `11011` is `16 + 8 + 0 + 2 + 1`. It's similar to base 10 where you multiply every digit by 1, 10, 100, 1000... https://www.wikihow.com/Convert-from-Binary-to-Decimal – giusti Sep 15 '19 at 20:28

1 Answers1

2

The example given has nine bits, not eight: a "1" and eight "0"s.

First you must know what form of binary number it is, as there are several conventions, such as unsigned, signed, binary coded decimal, etc.

Assuming that this is a simple, unsigned binary number, the nine bits have the following values: 256, 128, 64, 32, 16, 8, 4, 2, and 1. To find the value in decimal, add up all the values that have a "1" in that position. In this case, the number in decimal is simply 256.

Another example might be: 010001001 In this case, you add 128, 8, and 1, to get 137. This can also be represented by an eight-bit number: 10001001

If, on the other hand, this is a signed number, it's more complicated. For a signed nine-bit number (which is not often encountered), the ninth bit on the left says whether it's negative or positive, with a "1" indicating negative. In the "twos complement" form, the remaining bits are inverted and then 1 is added. In this case, 00000000 is inverted to 11111111, then 1 is added, making it 100000000, or 256. Thus the number is -256.

Elhem Enohpi
  • 292
  • 2
  • 7