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

  • Home
  • SEARCH
  • 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 7644883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:47:47+00:00 2026-05-31T09:47:47+00:00

I don’t know how to type this in to google, so I’m asking this

  • 0

I don’t know how to type this in to google, so I’m asking this here.

In programming, do operators take different amounts of time or CPU usage? For example would:

x = y + z

take less amount of time/CPU than:

x = y * z

?

I know it is not noticeable, if at all. Just a curious question.

Also, if you could include as many operators as possible such as +=, -=, *=, and /= along with all normal operators.

Thank you!

  • 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-31T09:47:48+00:00Added an answer on May 31, 2026 at 9:47 am

    There is no master list for all languages, data types, CPUs, and so on, because there is just too much variability.

    In some languages, operators are just syntactic sugar for full dynamically-determined type-dispatched function calls, so “a + b” could wind up being a complicated function call that takes minutes, while “a * b” might be a simple function call that takes milliseconds—or vice versa.

    In languages that have fixed, compile-time types (including C++ as well as C even though C++ has overloading), you can determine at compile-time what’s going to get invoked, which helps pin things down a lot, but still does not give you a final answer. (See also Dan D and Alex’s answers.)

    “Augmenting operators” (+= and so on) are usually just shorthand for assignment-after-expanded-operation. The actual operation takes the same amount of time. In languages with dynamic type dispatch, sometimes you cut off some auxiliary (non-operator) work as well since the augmenting operation need only look up the type of the variable once. With static (compile-time) typing, as long as the compiler is reasonably smart, simple a += b type operations never save anything over a = a + b at runtime, they are just easier to read. More complicated cases, like p->q->r->s += t, can actually save time since (in tricky cases) the p->q->r->s evaluation has to be done repeatedly if it’s written out repeatedly.

    As for the underlying CPU operations, there are some rules of thumb, but you have to haul out the appropriate CPU manuals to see which ones apply:

    • For integers, addition, subtraction, and logical operations like and/or/xor are never any slower than any other operation
    • For integers, multiplication is “harder” than addition, i.e., may be slower than addition etc, but may still be very fast as long as there is sufficient CPU-power dedicated to it; and division may be slower than multiplication, or may still be fast
    • For floating point operations, addition and subtraction are “harder” than multiplication and division, so they may be slower (or not, again it depends on how much transistor real estate there is dedicated to the FPU)
    • If there is no FPU, floating point is likely slower than integer
    • If there is a barrel or funnel shifter, shifts are always fast, but if not, shifts may take longer depending on “how far” the shift goes (e.g., x >> 4 may be slower than x >> 1)
    • In modern CPUs, the instruction scheduling @Alex mentioned above may or may not depend on the order of instructions, e.g., it may help to intersperse FPU instructions among integer-unit instructions (or it may not)
    • Cache effects (including placement of branches near particular points in cache lines as well as multi-level cache misses, and also TLB misses) can completely swamp the effects of careful instruction scheduling on some CPUs

    These kinds of things make writing modern compiler-optimizers pretty tricky. 🙂

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

Sidebar

Related Questions

Don't know how to google for such, but is there a way to query
(Don't know if this is strictly on-topic, but I don't see any better Stack
Don't know if this has been asked before, so point me to another question
Don't know if anyone can help me with this or if it's even possible.
Don't know whats exactly going on, but it's definitely killing my time for nothing.
I don't know: if this works. if it's a good idea. what it is
I don't know if this question is trivial or not. But after a couple
Don't know what's wrong here, when I run the application it says Specified method
Don't know if this is the right place to ask this, but I will
Don't know why this is happening, but after submitting a form via JS (using

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.