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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:34:25+00:00 2026-05-25T12:34:25+00:00

My aim is to get two numbers and perform an corresponding to the values

  • 0

My aim is to get two numbers and perform an corresponding to the values they hold:

For ex.. Let the vars be x and y.

I need to compute the value of another var z, as follows:

z = x + y // if x = y = 1

z = x – y // if x = 0 and y = 1

Since i need to use it several times, it would not be efficient to use if else within a loop.

What i basically require is like a macro…. preferably using #define., like if it were to be used once:

#define x + y 1 replaces x+y with 1, but does not depend on the values of x and/or y

Is there any way I could replace x+y with 1, x-y with 0 and so on…

  • 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-25T12:34:26+00:00Added an answer on May 25, 2026 at 12:34 pm

    If the vars are integers/any other primitive type you can’t improve the performance, since the compile will usually translate it one assembly code line. such as sub eax, ebx

    Anyhow, as mentioned before, you can’t do it on compile time since x,y values are not known at compile time.

    you can hint the compiler to save x and y on a register using the register keyword, which will save the variables on the CPU registers in order to preform faster calculations.

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

Sidebar

Related Questions

I am trying to get an AIM Bot set up in C# and I
I aim to filter my Google results right at terminal such that I get
I'm working on checkBoxTree in GWT-EXT 2.0.3 with Java. My aim is to get
My aim is simply to display two optional URL parameters on an index page.
I try to call skype instance by COM on F#. A aim is get
My aim is to get a json array like this one: var args =
SVN and CVS are two very different systems that aim to address the same
Shortened Aim: To pass a variable via $.POST to a PHP file (get.php), and
How can I get all the IM userIDs stored for a certain contact (AIM,
The javascript does not get value from the web method. It says undefined for

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.