| | |
Range of int
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
I have never seen a byte defined by anything other than 8 bits, although I don't thinnk the c or c++ standards specify its size. Here is just one of many examples.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
•
•
•
•
>Byte is not defined as 8 bits then what is it defined as?
It's defined as whatever the implementation wants. The standard only specifies that sizeof ( char ) be 1, and at least 8 bits. That happens to be the most common definition of a byte, but systems other than your PC also support C and don't have the same definition.
>it wouldn't be surprising for sizeof(char) to be 1, yet that it would be 32 bits?
Sure, why not?
>Or is it determined by the actual implementation of your C library?
It's determined by the compiler, not the library. Internally, a compiler will typically match the hardware for performance reasons, and the library would be written to match the compiler.
Sure, why not?
>Or is it determined by the actual implementation of your C library?
It's determined by the compiler, not the library. Internally, a compiler will typically match the hardware for performance reasons, and the library would be written to match the compiler.
New members chased away this month: 3
•
•
Join Date: Feb 2007
Posts: 7
Reputation:
Solved Threads: 0
Hi friend.
This is goutham from India.
Ur doubt is that why is char range -128 in the negative side.
The most significant bit is sign bit.
So the bits available for storing magnitude is 7.
If sign bit is 0,the number is positive and the magnitude is stored in conventional binary form.
If sign bit is 1,the number is negative and the magnitude is stored in two's complement form.
For example, +1 is stored as 00000001.
-1 is sored as 11111111.
-128 gets 10000000.
If u still cant get it reply me.
bye
This is goutham from India.
Ur doubt is that why is char range -128 in the negative side.
The most significant bit is sign bit.
So the bits available for storing magnitude is 7.
If sign bit is 0,the number is positive and the magnitude is stored in conventional binary form.
If sign bit is 1,the number is negative and the magnitude is stored in two's complement form.
For example, +1 is stored as 00000001.
-1 is sored as 11111111.
-128 gets 10000000.
If u still cant get it reply me.
bye
•
•
•
•
I have never seen a byte defined by anything other than 8 bits, although I don't thinnk the c or c++ standards specify its size.
Last edited by Dave Sinkula; Feb 19th, 2007 at 3:15 am.
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
![]() |
Similar Threads
- (Noob) need some help w/ Prime Numbers (C++)
- Targeting a number within a set of integers (C)
- Whats wrong with this class??? (C++)
- random number generator (C++)
- Base converter (C++)
- I don't know how to start to determine what hand of the poker, any ideas??? (Java)
Other Threads in the C++ Forum
- Previous Thread: Failing an input
- Next Thread: Time check problem
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays assignment beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete developer display dll email encryption error file forms fstream function functions game generator getline givemetehcodez graph homeworkhelper iamthwee ifstream image input int java lazy lib loop looping loops map math matrix memory multidimensional multiple newbie news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return sorting string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






