CoolInterview.com - World's Largest Collection of Interview Questions
Start Your Own website Now
Sponsored Links

Interview Questions
Our Services

Get 9,000 Interview Questions & Answers in an eBook.


  • 9500+ Pages
  • 9000 Question & Answers
  • All Tech. Categories
  • 14 MB Content

    Get it now !!



    Send your Resume to 6000 Companies


  • INTERVIEW QUESTIONS LANGUAGES C DETAILS
    Question :
    I have been replacing multiplications and divisions with shift operators, because shifting is more efficient.
    Category C Interview Questions
    Rating (0.3) By 9 users
    Added on 11/17/2011
    Views 168
    Rate it!
    Answers:

    This is an excellent example of a potentially risky and usually unnecessary optimization. Any compiler worthy of the name can replace a constant, power-of-two multiplication with a left shift, or a similar division of an unsigned quantity with a right shift. Furthermore, a compiler will make these optimizations only when they're correct; many programmers overlook the fact that shifting a negative value to the right is not equivalent to division. (Therefore, when you need to make sure that these optimizations are performed, you may have to declare relevant variables as unsigned.)



    If you have the better answer, then send it to us. We will display your answer after the approval.
    Rules to Post Answers in CoolInterview.com:-

  • There should not be any Spelling Mistakes.
  • There should not be any Gramatical Errors.
  • Answers must not contain any bad words.
  • Answers should not be the repeat of same answer, already approved.
  • Answer should be complete in itself.
  • Name :*
    Email Id :*
    Answer :*
    Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
    Process Verification  Enter the above shown code:*
    Inform me about updated answers to this question

       
    Related Questions
    View Answer
    People claim that optimizing compilers are good and that we no longer have to write things in assembler for speed
    View Answer
    How can I swap two values without using a temporary?
    View Answer
    Which is more efficient, a switch statement or an if else chain?
    View Answer
    Is there a way to switch on strings?
    View Answer
    Is there a way to have non-constant case labels (i.e. ranges or arbitrary expressions)?
    View Answer
    Are the outer parentheses in return statements really optional?
    View Answer
    Why dont C comments nest?
    View Answer
    Why isnt there a numbered, multi-level break statement to break out
    View Answer
    There seem to be a few missing operators ...
    View Answer
    Does C have circular shift operators?
    View Answer
    Is C a great language, or what?
    View Answer
    If the assignment operator were ...
    View Answer
    Does C have an equivalent to Pascals with statement?
    View Answer
    Why doesnt C have nested functions?
    View Answer
    What is assert and when would I use it?
    View Answer
    How can I call FORTRAN?
    View Answer
    What is C Programing language?
    View Answer
    What is hashing in C?
    View Answer
    How can I find the day of the week given the date?
    View Answer
    Was 2000 a leap year?
    View Answer


    Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.

    View ALL C Interview Questions

    User Options
    Sponsored Links


    Copyright ©2003-2014 CoolInterview.com, All Rights Reserved.
    Privacy Policy | Terms and Conditions

    Download Yahoo Messenger | Placement Papers| FREE SMS | ASP .Net Tutorial | Web Hosting | Dedicated Servers | C Interview Questions & Answers

    Testing Articles | Testing Books | Testing Certifications | Testing FAQs | Testing Downloads | Testing Interview Questions | Testing Jobs | Testing Training Institutes


    Cache = 1.734375 Seconds