Microsoft Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
0
of 0 vote

319, 63.5, 1/16, 5.390625 can be represented accurately.
0.1, 1.32 can't be.

- PP June 10, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Hey PP, can you please explain or direct me to an appropriate link?

- CB August 01, 2007 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Can you please justify your answer?

- AlgoFreak June 11, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

.1 binary comes to be 0, 1.32 becomes repeating after some time. but similarly, 63.5 and 63 has binary = 111111, 5.390625 and 5 equals 101 in binary. difficult to say that 63.5 and 5.390625 can be represented accurately.

- codebug June 12, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

hi,guys

PP is right.

Refresh your CS basics, please.

- passby June 23, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

pp is right because:

0.1 = 1/10. it's not possible to get a combination of powers of (1/2) that add up to 1/10.
1.32 = similarly, 32/100 = 8/25. that number cannot be expressed as a sum of powers of (1/2) either.

- rts October 10, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

@rts; so is that the general rule to find if a number can be represented exactly in binary ? .. see if it can be represented as a sum of powers if (1/2)

- AlgoFreek October 28, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

except 319, other integers can not be represent in binary correctly. I have conclude this using calculator.

- kk December 07, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

To convert numbers between 0 and 1, take the decimal expression and repeat-
edly multiply it by 2. At each step, keep track of the integer part of the
result but do not carry it along in subsequent multiplications. For
example, convert decimal 0.7 to binary:
0.7 * 2 = 1.4
0.4 * 2 = 0.8
0.8 * 2 = 1.6
0.6 * 2 = 1.2
0.2 * 2 = 0.4
0.4 * 2 = 0.8
0.8 * 2 = 1.6
0.6 * 2 = 1.2 etc. Note that we have started to repeat previous
results. Now read the integer parts occurring on
the right side, from the top down: the binary
representation of decimal 0.7 is 0.1011001100...
where the "1100" repeats forever.
so whatever number after decimal ends in 5 will become 0 eventually following above procedure and wil not be non-repeating..... therefore can be represented accurately.


319 (or 319.0), 63.5, 1/16(or 0.0625), 5.390625 can be represented accuratley in binary.

- PC February 02, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

good

- Anonymous June 12, 2008 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

How 5.390625 can be expressed in binary...

- xxx July 25, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

5.390625 should be 101.011001

- dandy September 03, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Online calculator to convert floating point number to binary. Quite useful!
http://babbage.cs.qc.cuny.edu/IEEE-754/Decimal.html

- vamalhotra April 24, 2009 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More