+5 0101

+ -5 1010

------------

-0 1111

can someone tell me why -5 is 1010, I dont understand, and where can I read more about this.

You'll find information in the first chapter of the Art Of Assembly Language by Randall Hyde :

http://webster.cs.ucr.edu/AoA/Windows/HTML/DataRepresentationa5.html#999509

http://webster.cs.ucr.edu/AoA/Windows/HTML/DataRepresentationa5.html#999509

Is only a representation, we need to be consistent whit our representations.. or coherent ;).

If you check the 0 and 1s are switch. -5 instead of 0101=1010 the bits are inverted, see the 01 from the first one and the other one. Hope it helps.

01 the contrary is 10 I guess.

1 -1

01 the contrary is 10 I guess.

1 -1

Rammstein,

To obtain the ones complement of any number, simply invert the bits.? Inverting 5=0101, one obtains -5=1010.?

Just about any book on logic or computer science will give a brief on ones complement arithmetic.? Ratch

can someone tell me why -5 is 1010, I dont understand

To obtain the ones complement of any number, simply invert the bits.? Inverting 5=0101, one obtains -5=1010.?

and where can I read more about this

Just about any book on logic or computer science will give a brief on ones complement arithmetic.? Ratch

By the way, 1's complement and 2' complement is defined to any base but I not remember exactly how is :S...

:/

CPUs use sign-module-2 instead of sign-module-1 (which is presented here).

in sign module 2 we have:

+5 0101

-5 1011

----------------

0 0000

zero (without any stupid negations). that's how CPU work, so you should focus on SM2, not SM1.

/

CPUs use sign-module-2 instead of sign-module-1 (which is presented here).

in sign module 2 we have:

+5 0101

-5 1011

----------------

0 0000

zero (without any stupid negations). that's how CPU work, so you should focus on SM2, not SM1.

/

ti_mo_n,

No such thing as sign-module whatever.? Do you mean signed-magnitude representation?? In any case, the INTEL CPU uses twos complement arithmetic.? Not all CPUs use twos complement arithmetic, however.? The original poster asked a question about ones complement arithmetic.? Ratch

CPUs use sign-module-2 instead of sign-module-1 (which is presented here).

No such thing as sign-module whatever.? Do you mean signed-magnitude representation?? In any case, the INTEL CPU uses twos complement arithmetic.? Not all CPUs use twos complement arithmetic, however.? The original poster asked a question about ones complement arithmetic.? Ratch

By the way, 1's complement and 2'? complement is defined to any base but I not remember exactly how is :S...

No, the pair, 1's complement and 2's complement, are associated only with binary.

For any radix (also known as number base), there is a radix complement and a (radix - 1) complement.

So for decimal numbers, you have 10's complement and 9's complement.

And 2's complement can be used with trinary (base 3) numbers, although it's not the same as the binary 2's complement. Binary two's complement of 10 is 10, trinary two's complement of 10 is 12.

No such thing as sign-module whatever.

Yeah. Now i had the time to thoroughly check this out. the name sing-module- is a short for "'s complement, expressed as 'sign' digits, followed by 'module' digits.

In any case, the INTEL CPU uses twos complement arithmetic.? Not all CPUs use twos complement arithmetic, however.

I don't count other CPUs, since there's a 99% chance, that i'll never use them :)

The original poster asked a question about ones complement arithmetic.

I thought that he wanted to learn x86 ASM arithmetic and that he was doing it the long way (through 1's compl.) so i proposed (assuming, that he may not know that) that he can switch to 2's complement, which is (imho) easier and more practical (in x86-asm sense) to learn.

sorry for the misunderstanding.