Home > computing > Twos complement and the Microsoft interview

Twos complement and the Microsoft interview

March 15th, 2010

Many years ago on March 13th (the day before Pi day), I interviewed for a summer position at Microsoft. I was a freshman in college, and was two months into my first computer science course ever. I knew little about computing at the time, and had a desktop computer built mostly from parts I found in the dumpster.  My operating system was Debian Linux 2.0, since I didn’t have a copy of Windows. Indeed, it was ironic that I was interviewing for a M$ position.

It is shocking to recall how naive I was. I borrowed a suit and dress shoes from a guy named Alex who lived down the hall from me. I had no idea what a real interview entailed. Sure, I’d swept movie theater floors, washed toilets, cut trees, built houses, but never had a desk job. That is a different beast. The interview began with about a minute of pleasant conversation, and degenerated into a brain teaser session. For those of you who lived only in the Google era, convoluted brain exercises during tech interviews existed ages before Google came along.

Remarkably, I managed through about ten problems involving spilled water, 2-quart containers, and 50-cent pieces.

“Good, ” the interviewer declared, “most people never get more than two of these correct, but unfortunately we still have to check your computer science knowledge. I’ll give you an easy one, since you did so well on the logic puzzles.

“What’s negative 6 written in 8-bit twos complement notation?”

F-ck.

Twos complement is a fundamental notation found in logic systems. In integrated circuits, each wire has two states, on or off. There is either electricity flowing through the wire, or not. A wire with power is represented in binary as a ’1′. All calculations are grounded on the twos complement system. All computing circuitry invokes logic represented by twos complement. With an 8-bit register, the number 6 is represented simply in binary notation, like this:

00000110

Negative numbers are represented by inverting the bits of their positive counterparts, and adding ’1′. Thus, -6 looks like this:

00000110 => 11111001 => (add 1) => 11111010

Any geek who tinkers with computer science would have known that. Not me. I was unable to write ‘-6′ in twos complement notation, and did not get the job. However, I received a Razor scooter as a consolation prize and was offered a priority internship consideration the next year.

I never followed up on that position, and am now an ophthalmology resident. It is incredible how much one event can impact your career.

computing ,