Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4040664
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:46:52+00:00 2026-05-20T12:46:52+00:00

Recently I had a question on the interview – I was asked to compare

  • 0

Recently I had a question on the interview – I was asked to compare bitwise operations in performance terms.

Like, give a brief description of the performance of different bit operations.

I guess this question could is pretty general and pretty machine-specific, but I also think there should be some general rules about this, which you have to mention (and I didn’t :).

So – what would you answer?

I probably should also say, that it may be a good idea to compare their performance in C (or C++, whatever), because I assume that these languages give more space for the compiler to perform bit-related optimizations.

Thank you.


Okay, the full problem context.

The interview had several sections and some of them were really a piece of cake, some were a nightmare. Bit-related section was kind of tough and including the questions like:

  • Floating point number specifications, float, double

  • Fast float->int conversions (and even faster one if you know the range)

Those weren’t very tough, but as the last question in this bit-related section I was asked to enumerate bit operations I know and compare their performance.

I answered something not really descriptive like “it’s architecture, compiler, … specific, it won’t actually matter, bitwise is already pretty low-level”, but I guess this answer sucks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T12:46:53+00:00Added an answer on May 20, 2026 at 12:46 pm

    I would imagine they mean comparing bit operations to arithmetic equivalents.

    For example, “is a = (a>>1) faster than a = (a / 2)?”

    In many cases, simple operations like this will (for various reasons including software and hardware optimisations, pipelining, caching, etc) effectively take 1 CPU cycle, so on modern processors you are unlikely to see a difference – but if they run many instructions in parallel through multiple ALUs then you may still benefit from better utilisation of the CPU’s parallel pathways if you mix arithmetic and bitwise operations. If you write in a higher level language then the compiler is very likely to optimise your code to use whatever is the better form, so you’ll see the same performance regardless of which way you write your code!

    However, there are cases where bitwise operations can be significantly faster than simple arithmetic/logic – for example, you can apply some operations to all the bytes in a 32-bit or 64-bit value with a few bitwise operations (that effectively process all the bytes simultaneously), which would otherwise take a lot of looping and comparing logic to do incrementally. See here for some great examples of what can be achieved. In these cases there is often a significant performance benefit to be gained. (although the exact gain can depend a lot on the CPU you’re targeting)

    (Alternatively, they may have just meant “is a shift operation faster than an XOR”, in which case with modern processors in most cases the answer is probably “no” – most bitwise operations are quick. But that would be a pretty pointless question to ask…)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is one of an interview question which I had recently. I would like
I recently had this question in an interview and this is what I came
I recently had an interview where I was asked to connect to the companies
I have recently had two telephone interviews where I've been asked about the differences
I recently had a question about String and String interning - pretty simple question
I recently had a question answered about a multi-computer git development setup, and the
Recently I had this question , and everything worked properly until I sent it
I had an issue recently (see my last question) that led me to take
Please see here for a question I recently asked. The only answer you should
I recently had a need to interpret a DEC 32-bit floating point representation. It

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.