30 Day Risk-Free Guarantee:
100% money back if you're unsatisfied.
Book (308 Pages):
  • 150 Programming Interview Questions and Solutions
  • Five Proven Approaches to Solving Tough Algorithm Questions
  • Ten Mistakes Candidates Make -- And How to Avoid Them
  • Steps to Prepare for Behavioral and Technical Questions
  • Interview War Stories: A View from the Interviewer's Side
  • Book Preview and More Info

Video (One Hour):
  • Watch CareerCup's founder perform a totally unscripted technical interview of a candidate.
  • Overview of what interviewers look for in software engineering jobs.
  • Technical questions with white-boarding coding where the candidate does well - and struggles.
  • Interviewer reviews with what went well and poorly.
  • Video Preview and More Info

Resume Review (24 - 48hr)
  • Get your resume reviewed by a trained engineering interviewer. More Info
All Products / Services


Express Prep Package (Book)
$29.99 for e-book | $32.45 for paperback
Buy E-Book Buy on Amazon


Standard Prep Package (E-Book & Video)
Emailed Instantly | $39.99
Buy Standard

Elite Prep Package (E-Book, Video & Resume)
Emailed Instantly | $99.99
Buy Elite
 



Which (one or more) of the following numbers can't be represented accurately in binary?

0.1, 319, 63.5, 1/16, 1.32, 5.390625

13


PP on June 10, 2007 |Edit | Edit

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

CB on August 01, 2007 |Edit | Edit

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

AlgoFreak on June 11, 2007 |Edit | Edit

Can you please justify your answer?

codebug on June 12, 2007 |Edit | Edit

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

passby on June 23, 2007 |Edit | Edit

hi,guys

PP is right.

Refresh your CS basics, please.

rts on October 10, 2007 |Edit | Edit

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.

AlgoFreek on October 28, 2007 |Edit | Edit

@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)

kk on December 07, 2007 |Edit | Edit

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

PC on February 02, 2008 |Edit | Edit

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.

Anonymous on June 12, 2008 |Edit | Edit
xxx on July 25, 2008 |Edit | Edit

How 5.390625 can be expressed in binary...

dandy on September 03, 2008 |Edit | Edit

5.390625 should be 101.011001

vamalhotra on April 24, 2009 |Edit | Edit

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

Add a Text Comment | Add Runnable Code
Name:
Comment:

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








Amazon (1033)Bloomberg LP (403)Qualcomm (117)Adobe (88)Goldman Sachs (78)NetApp (49)IBM (43)Morgan Stanley (33)CapitalIQ (30)Sophos (25)Achieve Internet (23)Electronic Arts (19)Motorola (18)Research In Motion (17)Flipkart (16)
Microsoft (867)Google (141)NVIDIA (98)Yahoo (82)Epic Systems (69)Expedia (47)VMWare Inc (43)Apple (32)Cisco Systems (28)Facebook (23)Infosys (22)Agilent Technologies (19)Sage Software (17)Deshaw Inc (16)FlexTrade (15)
More Companies »
Software Engineer / Dev... (1062)Financial Software Deve... (170)Testing / Quality Assur... (56)Analyst (35)Virus Researcher (25)Field Sales (15)Developer Program Engin... (9)Front-end Software Engi... (6)MyJoB (5)area sales manager (4)Assistant (3)Cabin crew (2)Accountant (1)personnel (1)Intern (1)
Software Engineer in Te... (288)Program Manager (65)Development Support Eng... (47)INTERN(MSIDC) (28)Web Developer (18)System Administrator (10)Consultant (10)Production Engineer (5)Associate Technology L2 (5)AcquireKnowledge (4)Product Security Engine... (3)Solutions Architect (2)Gamer (1)mts (1)Fresh graduate interview (0)
More Job Titles »
Algorithm (1073)Terminology & Trivia (294)C (166)Object Oriented Design (159)Java (121)Testing (114)Arrays (101)Operating System (78)Database (70)Linked List (62)String Manipulation (56)Networking / Web / Inte... (44)Threads (36)Linux Kernel (33)PHP (22)
Coding (511)C++ (204)Behavioral (159)Data Structures (155)Experience (116)Brain Teasers (111)Computer Architecture &... (79)General Questions and C... (73)Trees and Graphs (69)Math & Computation (57)Application / UI Design (45)Ideas (38)System Design (35)Puzzles (30)Bit Manipulation (20)
More Topics »
CareerCup Official Interview Book Daily Questions Requests for Help Mock Interviews Video for Cracking the Coding Interview Job Placement Service CareerCup Blog
My Profile Edit Profile & Email Settings Sign Out