i just wanted to ask whats the unsinged char and int ? and DWORD
becasue i didnt see any tutrial that talk abt them :S
i just wanted to ask whats the unsinged char and int ? and DWORD
becasue i didnt see any tutrial that talk abt them :S
The unsigned means that the type has a non-negative range but same size and alignment requirements as the corresponding signed type (i.e., signed char and int in this case). For DWORD, read MSDN.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
The unsinging character is mute.
Just kidding! "unsigned" means it has no positive or negative sign (which means it is always a positive number). Without the sign, you have an extra bit to use as part of the stored value. Everytime you add a bit you double the possible range of values, so while a normal char can be from 0 to 127 (7 bits) with the sign (- or +), an unsigned char is a full 8-bit number, 0-255, but it cannot be set negative.
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
what about unsinged char ? how will it non nagative and its just a char? ?
That would be the case for sign and magnitude and one's complement, but with two's complement the range of an 8-bit signed char would be [-128,127]. Also, it is implementation defined whether char is signed or unsigned.Originally Posted by MK27
You might want to rephrase that using proper English. I am afraid that I do not understand your question considering what MK27 and I have stated.Originally Posted by lolguy
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
The unsinged character avoids open flame. Ha ha ha again! Don't even ask about the unhinged char.
A char is a value. These values translate to alphanumeric symbols when you use printf, etc. Have a look at the ASCII table. So for example:
are exactly the same thing. The first form is for convience.Code:char X='X'; char X=88;
I did not know this -- I suppose that's because we don't need a "-0"?Originally Posted by laserlight
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
oh thanks alot i understand it now
I am not sure if we can consider the lack of a negative zero as the reason (perhaps the fact that the sign bit has a -(2^N) value instead of -(2^N - 1) value is the reason), but either way it is the way the mathematics works out.Originally Posted by MK27
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Hey look my 666th post!
That the sign is the first bit and that if set the remaining bits are flipped I can understand. If this is the math:
then I don't quite get it: wouldn't that mean if the number is 1000001, the number should be 128-1+1=128, when actually 10000001 is -127. And 10000000 (-128) would be 128-0+1=129?Originally Posted by Wikipedia, the free encyclopedia
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
Since the most significant bit is negative, it should be: -128 + 0 + ... + 0 + 1 = -127.Originally Posted by MK27
Why do you add the 1 when all the remaining bits are unset?Originally Posted by MK27
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Is this definition wrong then?
Again, flipping the bits makes sense (I imagine this is what really happens) but this math formula is what looks unsinged to me. Altho either way I can't find -128 unless it is just treated as a special case, 10000000, which would have been 128 unsigned.subtracting the number from a large power of two and adding 1
The only way I can see to describe this is to simply say 2N-value*sign, which will invariably work. I assume that the computer does not really use these silly formulas anyway -- Math people are ridiculous
Last edited by MK27; 01-18-2009 at 11:07 AM.
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
Probably: take a look at the "Calculating two's complement" of the same article where it gives a correct formula without the addition of 1.Originally Posted by MK27
EDIT:
There is no need to multiply by a sign value because the operation is performed with a fixed number of bits.Originally Posted by MK27
Last edited by laserlight; 01-18-2009 at 11:17 AM.
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge