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 9213059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:39:44+00:00 2026-06-18T01:39:44+00:00

In order to evaluate a multiplication you have to evaluate the first term, then

  • 0

In order to evaluate a multiplication you have to evaluate the first term, then the second term and finally multiply the two values.

Given that every number multiplied by 0 is 0, if the evaluation of the first term returns 0 I would expect that the entire multiplication is evaluated to 0 without evaluating the second term.

However if you try this code:

var x = 0 * ComplexOperation();

The function ComplexOperation is called despite the fact that we know that x is 0.

The optimized behavior would be also consistent with the Boolean Operator ‘&&’ that evaluates the second term only if the first one is evaluated as true. (The ‘&’ operator evaluates both terms in any case)

I tested this behavior in C# but I guess it is the same for almost all languages.

  • 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-06-18T01:39:45+00:00Added an answer on June 18, 2026 at 1:39 am

    Firstly, for floating-point, your assertion isn’t even true! Consider that 0 * inf is not 0, and 0 * nan is not 0.

    But more generally, if you’re talking about optimizations, then I guess the compiler is free to not evaluate ComplexOperation if it can prove there are no side-effects.

    However, I think you’re really talking about short-circuit semantics (i.e. a language feature, not a compiler feature). If so, then the real justification is that C# is copying the semantics of earlier languages (originally C) to maintain consistency.

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

Sidebar

Related Questions

I have written the following algorithm in order to evaluate a function in MatLab
I have an array that contains values that I'm working on (in a specific
I have a class that holds on to a delegate, in order to lazily
I have developed a feature extraction algorithm for images. In order to evaluate the
Currently, in order to evaluate elist in Emacs, I need to position the cursor
Order deny,allow deny from all allow from xx.xx.x.xx RewriteRule . - [F] I have
Is there a way to evaluate the order of an array? I want to
Logically, one would think that the foreach loop in C# would evaluate in the
I am trying to figure out MongoDB in order to evaluate whether it is
I need to evaluate the sum of the row: 1/1+1/2+1/3+...+1/n. Considering that in C++

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.