What does this mean and how do I declare an array that holds 32-bit unsigned integer in C?
What does this mean and how do I declare an array that holds 32-bit unsigned integer in C?
unsigned long int foo;
This should be at least 32 bits.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
What makes an unsigned int any different from a normal int?
That is all explained in every C book there is....or else theres tons of articles about it on the net
So unsigned only allows positive numbers?
unsigned numbers are cryptographically insecure versions of signed numbers
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Ha ha!Originally Posted by Salem
Basically, let's say you have an 8-bit int. On most computers one of the bits keeps track of the sign: 01100101. If the bold bit is 1 the number is negative, otherwise it's positive. Unsigned ints don't do this.
If you understand what you're doing, you're not learning anything.
Since unsigned variables only allow whole numbers (positive (natural) numbers and zero), the extra bit that in signed numbers indicates the sign is part of the number. This means that you can numbers about twice as large in unsigned variables. eg
Code:unsigned char: 0 - 255 signed char: -127 - 127 unsigned short: 0 - 65535 signed short: -32767 - 32767
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.