0

In his blog post on 512 bit division, Remco Bloemen makes the following assertion:

... negation flips all high bits of a number up to but not including the least significant one

Why is that?

1 Answer 1

0

This is because the EVM uses the two's complement system to store signed values.

By definition, negating a number in two's complement involves two steps:

  1. Flip all bits.
  2. Add 1 to the flipped value.

The 1 is added at the end, so the least significant bit remains unchanged (it goes back to its original value, in a roundabout way).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.