Please answer me this

Recommended Answers

All 2 Replies

What kind of integer value? int? short? long? Something else?

There's no such thing as an integer with only 2 bits -- maybe you mean bytes instead of bits.

The number of bytes in an integer depends on what computer hardware architecture and compiler you are using -- c and c++ language do not specify how many bytes are in an integer -- it only says there is one byte in a char data type. Some 16-bit compilers such as Turbo C uses sizeof(int) is the same as sizeof(short) and sizeof(short) is two bytes. When you move to a 32-bit compiler such as modern gcc and Visual C++ you will find that sizeof(int) is the same as sizeof(long), which is 4 bytes while sizeof(short) is 2 bytes.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.