Can someone please explain why
select ~1
gives the result
-2
Perhaps there is a lot for me to learn about the actual bits of number types. What resource would you recommend?
Q: Can someone please explain why select ~1 gives the result -2?
A: For the same reason ~0 would give -1 :)
Here's a good article on "twos complement" arithmetic:
Most CPU architectures are two's complement (vs. one's complement). From the same article:
Two's complement is the easiest to implement in hardware, which may be the ultimate reason for its widespread popularity[citation needed]. Processors on the early mainframes often consisted of thousands of transistors – eliminating a significant number of transistors was a significant cost savings. The architects of the early integrated circuit-based CPUs (Intel 8080, etc.) chose to use two's complement math. As IC technology advanced, virtually all adopted two's complement technology. Intel, AMD, and Power Architecture chips are all two's complement.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With