5

Possible Duplicate:
What super-calculator do you use?

I need a calculator program that runs on Windows 7 that can do two's complement conversions. Specifically convert a two's complement to regular decimal or binary. I'm told that the Win 7 calc does this.

Can anyone give a clear, specific example of how to do this on the built-in calc (or any other freely available program)? Thanks!

6
  • Can you please tell me how one does that on the built in calculator? Thanks!
    – ssvarc
    Feb 15, 2010 at 15:33
  • 2
    View -> Programmer or Alt + 3
    – Robin Day
    Feb 15, 2010 at 15:34
  • I'm looking at the programmers view and I saw this calculator before I posted. I don't see here how to do coversions to/from twos complement and I would appreciate some specific help. Thanks!
    – ssvarc
    Feb 15, 2010 at 15:38
  • 1
    @ssvarc - Your question has been migrated here, where it is more adapted. To regain ownership over your question, you should associate your Super User account with your Stack Overflow one in user options. When done, I recommend you to edit your question according to your last comment. Because if your question remains the generic "looking for calculator program", then we have a duplicate here, and your question will be closed.
    – Gnoupi
    Feb 15, 2010 at 16:45
  • 2
    this question is not a duplicate of superuser.com/questions/21950/what-super-calculator-do-you-use -- while some of those tools might have the feature requested, this question also asks how to use that feature. please do not close this as a duplicate. Feb 15, 2010 at 17:33

2 Answers 2

3

The standard calculator has this built in.

Select View > Programmer (Alt + 3).

From PlanetMath:

Additionally, negative numbers are shown in two's complement (and the sign change key performs two's complement on the displayed value).

1
  • 2
    I'm looking at the programmers view and I saw this calculator before I posted. I don't see here how to do coversions to/from twos complement and I would appreciate some specific help. Thanks!
    – ssvarc
    Feb 15, 2010 at 16:09
0

There are 2 free scripting languages that are good calculators too:

  1. Octave http://www.gnu.org/software/octave/download.html
  2. Python http://www.python.org/

The solution for two's complement in each of those languages for the number 8923:

Octave

bitcmp(8923, 16)

where 16 is the number of bits in the result

56612

this is because octave only deals with positive numbers in bitwise operations

Python

~8923

results

-8924

To convert from binary to decimal

Octave

bin2dec("10001011011011")

result

8923

To convert from 2' complement to decimal

Octave

bitcmp(bin2dec("10001011011011"), 16)

result

56612

PS: Octave commands are supposed to work in Matlab too

5
  • I'm looking to convert from two's complement to decimal or regular binary.
    – ssvarc
    Feb 15, 2010 at 16:14
  • @Ssvarc I edited to show how to convert from two's complement
    – Jader Dias
    Feb 15, 2010 at 17:32
  • @Ssvarc the inverse operation of the two's complement is itself. So if you seek to convert to or from is the same thing
    – Jader Dias
    Feb 15, 2010 at 17:33
  • I still don't follow. Sorry. If what your trying to say is that a two's complement number and it's counterpart in regular binary is the same, then no, that is not correct. (I see that you realize this based on your examples above, so obviously there is something missing here.)
    – ssvarc
    Feb 17, 2010 at 6:49
  • @Ssvar I fear I couldn't make myself clear. What I am saying is that bitcmp(bitcmp(x)) is equal to x
    – Jader Dias
    Feb 17, 2010 at 14:24

Not the answer you're looking for? Browse other questions tagged .