Windows 10 Calculator to compute the Two's Complement value of a Binary representation

0

How do I use the Win10 calculator in Programmer mode to calculate the 2's complement value of the input binary representation. The calculator seems to treat the input binary sequence always an unsigned sequence. I was wondering if there is a way to make it treat the sequence as a 2's complement sequence instead.

Edit: As per the below comment by Peter, clarifying my question: I am looking to calculate the 2's complement value of a binary sequence. Sorry for the confusion.

rgbk21

Posted 2020-01-08T15:22:45.000

Reputation: 3

1Are you asking how to calculate the 2s complement, or are you asking whether it can treat an input sequence with the sign bit set as a negative number? – Peter Smith – 2020-01-08T15:51:47.933

Answers

0

There are simply no unsigned types in Windows calculator. If you turn on the top bit of the value then it's always signed. You can turn on the "Big toggling keypad" by clicking the button above the "Bit Shift" and then click on the top bit to see

Since 2's complement just mean the negated value, you simply press the +/- button on the left of the zero key and the 2's complement value of the current value will be taken

For example if you enter 2 and press the button then it'll become -2 in decimal, and a binary value with all ones except in the least significant bit. Press +/- again and the 2's complement of -2 will be displayed

Another thing to note is that the middle button determines how many bits you want to work with. If you're working with DWORD (i.e. 32-bit) then entering a 16-bit hex or binary value will always return a positive value, but if you change to WORD (16-bit) then the value will become negative if the 16th bit is 1

Calculator negative value example

phuclv

Posted 2020-01-08T15:22:45.000

Reputation: 14 930

Ah. I feel so stupid right now. Thank you very much. – rgbk21 – 2020-01-08T16:38:54.463