On Wed, Sep 8, 2010 at 8:40 AM, DG <dangets@xxxxxxxxx> wrote:
Whoops, I meant to say:Quick explanation/example:On Wed, Sep 8, 2010 at 12:51 AM, Bond <jamesbond.2k.g@xxxxxxxxx> wrote:
On Tue, Sep 7, 2010 at 11:14 PM, Bond <jamesbond.2k.g@xxxxxxxxx> wrote:On Tue, Sep 7, 2010 at 3:32 PM, Andreas Leppert <wudmx@xxxxxx> wrote:Hello,
I have encountered a problem on my 32 bit machine. Here some code
snippets:
typedef signed long s64;Ok here is an article which cleared my doubtsbut I am not clear with meaning of signed and unsigned.
With 8 bits you can represent (2 ** 8) -1 possible numbers. Unsigned numbers mean that the number cannot be negative so the numbers go from 0 -> 255 (0b0000 0000 -> 0b1111 1111) Signed numbers _can_ be negative so they represent the numbers in the range -128 -> 127 (0b1000 0000 -> 0b0111 1111)
The same thing applies to 32 bit integers. Both signed and unsigned use the same number of bits, but they represent different ranges of numbers. If your number is never expected to be negative, unsigned numbers give you a higher positive range.
To understand the negative numbering:
http://en.wikipedia.org/wiki/Twos_complement
with 8 bits you can represent 2 ** 8 (256) different numbers. Unsigned numbers go from 0 -> (2 ** 8) -1