On Wed, Sep 8, 2010 at 8:40 AM, DG <[email protected]> wrote:

>
>
> On Wed, Sep 8, 2010 at 12:51 AM, Bond <[email protected]> wrote:
>
>>
>>
>> On Tue, Sep 7, 2010 at 11:14 PM, Bond <[email protected]> wrote:
>>
>>>
>>>
>>> On Tue, Sep 7, 2010 at 3:32 PM, Andreas Leppert <[email protected]> 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 doubts
>>
>> http://www.linuxfordevices.com/c/a/Linux-For-Devices-Articles/ELJonlineBRWriting-Portable-Device-Drivers/
>> but I am not clear with meaning of signed and unsigned.
>>
>
> Quick explanation/example:
>
> 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
>
>
> Whoops, I meant to say:
with 8 bits you can represent 2 ** 8 (256) different numbers.  Unsigned
numbers go from 0 -> (2 ** 8) -1

Reply via email to