bool are generally 1 byte
char are generally 1 byte
short are generally 2 bytes and not smaller than chars
int are generally 4 bytes and not smaller than shorts
long are generally 4 bytes and not smaller than ints
long long are generally 8 bytes and not smaller than long
1 byte = 8 bits.
You can use sizeof to find the number of bytes a variable is.
A char is always one byte, at least as the standard defines a byte.
1 byte = 8 bits.
Not necessarily, although with the restrictions imposed by the standard (and if memory serves,) I believe a byte in C++ must always have at least 8 bits.
The standard or a byte is 8 bits, but it can vary depending on the compiler being used. A bit is the smallest unit of data measurement: it is either 1, or 0. A bit is represented by single-digit binary number (base-2 integer, aka 0, 1, 10, 11, 100, 101, 110, 111, ...). If you do some research, all you have to do is apply what you know about counting in base 10 (0-9, aka 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10...) to count in base-2 and base-16. :) This can also be used for hashing if you want to go further, when you use this to conver one base to another.
The number of bits in a byte can vary? I had no idea. Just checked wikipedia (very reliable) and it confirmed that. But does anyone have a single example of a target machine/processor with a byte-size which is not 8 bits?
I've seen processors which take 24 bit numbers instead of 32. Therefore integers compiled for these processors are not the standard 32 bits. But that's really the only variation of the standards that I've ever heard of.
That link describes that C++ allows this. I have no doubt of that. However wouldn't that depend more on the processor and OS architecture than the language used?
To communicate on a network with anything with TCP/IP you'd need to use 8-bit bytes. Any x84 x64 or ARM processors I believe would need 8-bit bytes. OSs might need to swap endian, but the size of the bytes are constant. Or perhaps I'm confused regarding the definition of a byte.
Edit: How about the definition of a nibble? Does it have any place in C++ or computer science in general? I generally think of a nibble as a single hex digit. A byte like 0x5c contains 2 nibbles: 0x5 and 0xC.
CHAR_BIT=16, uint8_t is not defined:
Texas Instruments C54x, C62xx and C64xx DSPs
Texas Instruments TMS32F28xx
BlueCore-5 chip from Cambridge Silicon Radio
CHAR_BIT=24
BelaSigna DSPs from On Semi
DSP56K/Symphony Audio DSPs from Freescale
DSP 56300 family
CHAR_BIT=32
Analog Devices 32-bit SHARC DSP
DSP 56156 from Motorola
Univac uses 9 bit bytes? Very cool. I've never programmed for one, or even used the terminal, but I've installed machines in rooms where these were sitting. I love how instead of having monitors they had printers with massive scrolls of paper. You had to read the most recent printouts to see what was sent out by the application. Life is so much simpler these days...
With TCP/IP there is a term octet which means 8 bits, so this avoids confusion about byte size. My basic understanding of it says that it doesn't necessarily mean that the information being sent is 8 bits per byte, as long as the communication signals have the correct number of bits, then the sending and receiving of information is interpreted by the OS. If TCP/IP defines everything in terms of octets then it will be easier for a TCP/IP application if a byte is 8 bits.
I have heard of Mainframes which run on 7 bits per byte, also of certain embedded systems on GPS satellites with only 5 bits per byte. And that 8 bits per byte was a thing that started with MS-DOS. Or at least it is a standard on PC's but not necessarily on other machines.
Guys where can i learn all this low level undertstanding
Any decent C++ book has a section on bitwise operations and usually they will go into a good amount of detail on what bytes and bits are. There is also plenty good resources on the internet like http://www.cprogramming.com/tutorial/bitwise_operators.html that can be helpful.
Just start digging and googling around I would say otherwise pick up a good C++ book like C++ Primer and dig into their section on it.
and what is TCP/IP
TCP/IP is a networking protocol that a lot of applications make use of. Well to be more exact it is actually two protocols TCP and IP. It would be a very lengthy forum post to get into all the details of TCP/IP, but a quick Google search for the basics on networking will provide you plenty of information.
But to sum it up TCP is a reliable stream based protocol. It guarantees delivery of the data that is transmitted unlike unreliable protocols like UDP which if a packet is lost it just continues on.
Guys where can i learn all this low level undertstanding
Study, practice, and time. There is no silver bullet, just the wide expanse of computer science[1].
and wrote:
And could you recomend me any other bookks
You ask this a lot, have you not got enough recommendations yet? At the moment, form what seen from you, you seem to be flitting around without having the basics do yet. You need to make a decision on what book (or other resource) you are going to start with and start at the beginning. When you have a problem, come here and ask specific questions about the problem you are having.
Oh what was the problem you were having? The source code is still available for download on their website. Here is the link: http://www.informit.com/store/c-plus-plus-primer-9780321714114
I think the sales_item.h file is in chapter 1 when you unzip it.