views:

154

answers:

3

MS calculator on windows 7 has a "programmers" mode. When I type in (in binary): 1111111111111111111111111111111111111111111111111111111111111111

and then click "Dec", the binary turns into -1. When I click Oct, the value turns into 1777777777777777777777

However, whenever I use an online converter, it doesn't work. I need to know how the calculator is doing this so I can emulate it in c++.

+1  A: 

Ever heard of 2s complement? It all depends (logically on the length of the binary number. Hardware lets you work with one word at a time, however.

Hamish Grubijan
+1  A: 

It's doing two's complement when you switch it to decimal. In octal form, it is doing a straight conversion.

CookieOfFortune
+7  A: 

It is using 64 bit two's complement notation. Basically, when you add one to 2^63 - 1, it overflows and you get -2^63. Wikipedia for more detail

recursive