Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 729 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why does -INT_MIN = INT_MIN in a signed, two's complement representation?

#11
We should know how we manage to make x to -x:
1. Flip all bits in x. Like 5 is 0101, and we get `1010` in this step;
2. Add 1 to what we get in last step. This time we get `1010 + 1 = 1011`.

And in the real machine, negative ones are always shown in 2's complement format, so 1011 presents -5(which is `-8 + 2 + 1 = -5`).

Now back to the question, `INT_MIN` in the real machine is `1` with 31 consecutive `0`.

So after the first step, you will get a number which is `0` with 31 consecutive `1` and it is `INT_MAX` in C language.

In the second step, add `1` to what we get from the last step, and the result is `1` with 31 consecutive `0`, which is also `INT_MIN`.

So `INT_MIN = -INT_MIN`
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through