## Microsoft Interview Question for Software Engineer / Developers

• 0

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.

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

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

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

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.

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

hi,guys

PP is right.

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.

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)

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.

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.

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

good

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

How 5.390625 can be expressed in binary...

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

5.390625 should be 101.011001

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

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.

### 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.