Bits bytes & Binary

closed account (1vD3vCM9)
Hey there, thanks for reading this.
I have programmed c++ for almost 4 months now, and it came to my attention that I MUST understand bits bytes and binary.
The only thing I understand from those 3 subjects is binary, how to convert integers into binary.
In this way:

I want to convert 18 into binary
128 64 32 16 8 4 2 1
18-16=2
2-1=1
0 0 0 1 0 0 0 1 0
That is true.
Can you explain how to convert from binary to decimal?
And the basics of bits and bytes?
Thanks.


closed account (1vD3vCM9)
No one? Well then.
Each digit in binary represents a power of two. In base 10, the rightmost is 20=1, then next is 21=2, then 22=3, and so on. If you sum those values you have the value of the whole number. Just do the arithmetic in base 10 and you'll have the answer.

A bit is a digit in binary; that is, it can hold a value of either 0 or 1.

A byte is, by common convention, just a sequence of 8 bits. Interpreted as a number, then, you could say a byte stores a number from 0 to 255.

These articles might be helpful in identifying what you don't know about these subjects so you can ask a more targeted question:
https://en.wikipedia.org/wiki/Bit
https://en.wikipedia.org/wiki/Byte
https://en.wikipedia.org/wiki/Binary_number
Topic archived. No new replies allowed.