2 power n
23 can be represented in binary as 10111 and would therefore require 5 bits to represent.
It depends on the type of integer (such as long, short, int and char) and the specific implementation of C++. The only guarantee is that a char must occupy one byte (sizeof(char)==1). An int is typically 32-bits (4 bytes), but only sizeof(int) can tell you for sure.
Type size of an unsigned integer is compiler specific. Most compilers will provide 4 bytes, but the size can range from 2 to 8, or (again) whatever the implementation provides. Note: 1. Maximum value: UINT_MAX (in limits.h) 2. Size in bytes: sizeof (unsigned)
In order to know how many bits/second there are in 1 frame/second, you need to know how many bits are in that frame. In a typical asychronous serial protocol with 8 bits per frame, the bit rate would be 0.125 bits/second. If you are talking the IP network layer of TCP/IP, then the frame size is very dependent on the underlying message payload and headers.The original question, by the way, is invalid. Its asks "how many bits does...", but it should have asked "how manys bits per second does...".
You design it as an inline function with a constant unsigned reference parameter. Since there are 12 inches to the foot, the return value is the product of the parameter and 12. However, you must also ensure the return type has enough bits to store the result. C++ example: inline unsigned int feetToinches( const unsigned int & feet ){ return( feet < 357913941 ? feet * 12 : 0 ); } The above example assumes an int is 32-bits wide. If the input is larger than 357913941 (feet) then there won't be enough bits to store the result, so zero is returned instead. If the input is non-zero and the return is zero, you know the conversion failed. We use unsigned data types because you cannot have a negative unit of distance. We use a reference parameter to prevent the parameter from being copied (not strictly necessary if the type will fit within a pointer variable, but good practice nonetheless). The parameter is constant because the function does not need to modify the parameter. It is inline because the code is not complicated and is a prime candidate for inline expansion, thus eliminating the need for a function call altogether.
8 bits if unsigned, 9 bits if signed
There are 16 decimal numbers that can be represented by 4-bits.
Using 5 bits, a total of (2^5) different numbers can be represented. This equals 32, allowing for values ranging from 0 to 31 in unsigned binary representation. If signed representation is used (e.g., two's complement), the range would be from -16 to 15, still totaling 32 distinct values.
6 bits
8 bits = 64 character
4
A total of 65,536 items can be represented with 16 bits. A total of 64 items can be represented with 6 bits and 1024 items with 64 bits.
1000
1024
With 5 bits, you can represent (2^5) different numbers, which equals 32. This includes numbers ranging from 0 to 31 in unsigned binary representation. If using signed binary representation (like two's complement), the range would be from -16 to 15, still allowing for 32 distinct values.
2
2^12=4096