11000111 is a decimal number, but it looks like you intended it to be a binary value. It's probably easier to handle if you use hex rather than binary. Or use a bitset.
Thankyou Chervil..
I was doing a Challenge. I had to Convert (199), (77) and (202). Into a byte each(199) Must go first.
Then from 'binary' to 'Hex' and combine the 'hex' together to get a 'decimal'.
I was trying to write a small code to do it.
Ok , So the '0x' tells it that i want to read a 'hex' value.!
Well, I only used hex as it was the easiest way to deal with the pseudo-binary values originally presented. You could just use the decimal values 199, 77 and 202 directly if that was the actual data given in the question. int id3 = 199 + (77<<8) + (202<<16);
There may be more to this question than this, I don't think the full details of the original challenge have been stated clearly.
A bit of googling has turned up this, which I think might be the actual question:
Let us take the following three decimal numbers:
199, 77, 202
Convert each one into a byte. (Even though 77 does not require all 8 bits to express itself, when dealing with a group of data, we usually keep it in a consistent form.) Now, take those three bytes and combine them to form a 24-bit unsigned integer. The 199 byte is the high byte (most significant) and so forth. Please enter that 24-bit integer in decimal form, and that is your answer. (Hint: your answer will not be '19977202'!)
If that is the actual question, then the solutions I gave so far have been wrong, for two reasons. Firstly, it used integer rather than byte values, and secondly the byte order in the result was incorrect.
For a byte value one might use an unsignedchar or uint8_t type. Similarly the result might be an unsignedint or uint32_t type.
Include header <cstdint> for the latter types, which are guaranteed to occupy the specified number of bits.