Home > Back-end >  Computer source and complement problem
Computer source and complement problem

Time:09-25

Everyone a great god, and everyone!
When the younger brother to write programs, found negative in a computer is stored in the form of complement, highest level is the sign bit
And the younger brother, using the 25 experiments including 25 - the source code of the binary is 1000 0000 0000 0000 0000 0000 0001 1001
25 complement is 1111 1111 1111 1111 1111 1111 1110 0111

Int main ()
{
Int a=0, b=0;
B=0 xffffffffe7;//- 25 complement
A=0 x8000019;//to 25 of the original code
Printf (" a=% d \ n ", a);
Printf (" \ n b=% d ", b);
getch();
return 0;
}
Why a=134217753 rather than 25; Why b=25, please god help me to answer it

CodePudding user response:

Your complement wrong,,,

Because: complement=source radix-minus-one complement + 1
So: source=complement - 1 to take the

1111 1111 1111 1111 1111 1111 1110 0111 minus one equals 1111 1111 1111 1111 1111 1111 1110 0110
Invert: 0000 0000 0000 0000 0000 0000 0001 1001 for the source code,,,

CodePudding user response:

You said "negative in a computer is stored in the form of complement"
So - 25, storage is 1111 1111 1111 1111 1111 1111 1110 0111, so the 25 source should be on the basis of calculation in this complement, rather than
1000 0000 0000 0000 0000 0000 0001 1001 this,,

CodePudding user response:

0 x8000019
0 x80000019

CodePudding user response:

Because: complement=source radix-minus-one complement + 1
So: source=complement - 1 to take the

1111 1111 1111 1111 1111 1111 1110 0111 minus one equals 1111 1111 1111 1111 1111 1111 1110 0110
Invert: 0000 0000 0000 0000 0000 0000 0001 1001 for the source code,,,
Pro, the 0000, 0000, 0000, 0000, 0000, 0000, 0001, 1001 should be is the source of 25,
  • Related