How to convert 32bit binary to decimal?

2.8k Views Asked by At

For example:

powers of two: 128 64 32 16 8 4 2 1

Decimal value: 192 168 168 20

Will convert to -

Binary value: 11000000 10101000 10101000 000101000

Question:

How to convert 110000001010100010101000000101000 (32bit) back to decimal, since the power of two goes up to 8, not to 32?

1

There are 1 best solutions below

0
On

You can do it the same way, with the various positions representing values from $2^0=1$ to $2^{31}=2,147,483,648$. Given the work you have done converting each byte, you can also recognize that each block of $8$ bits increases the exponent by $8$. Your lower order byte converts to $40$, not $20$. The value of the whole number is then $192\cdot (2^8)^3+168\cdot (2^8)^2+168\cdot 2^8+40$