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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:31:58+00:00 2026-05-13T13:31:58+00:00

I just ran into a piece of code that not only compiles, but gives

  • 0

I just ran into a piece of code that not only compiles, but gives the expected result (where x is an integer value):

int y = (int)(0.5 * x * x + + + 0.6 * x + 1.2);

It took me a while to figure out what happens and I must say it was an interesting operator problem. Without compiling the program, what are the results of the following operations and why?

int a = 1;
int b = 2;
int z = a + + + b;
int z1 = a + - + b;
int z2 = a + - - b;
int z3 = a - - + b;
int z4 = a - - - b;
int z5 = a +- b;

I still have one question, though: does the standard give such results or is it compiler specific?


Explanation:
Because the + and – operators have spaces between them, the “+ + +” sequence is not compiled as “++ +”, but as unary operators on the right member. So

int y = (int)(0.5 * x * x + + + 0.6 * x + 1.2);

actually gives:

int y = (int)(0.5 * x * x + 0.6 * x + 1.2);

which was the expected result.

So,

z  = a + + + b = a + + (+b) = a + (+b) = a + b = 3;
z1 = a + - + b = a + - (+b) = a + (-b) = a - b = -1;
z2 = a + - - b = a + - (-b) = a + (+b) = a + b = 3;
z3 = a - - + b = a - - (+b) = a - (-b) = a + b = 3;
z4 = a - - - b = a - - (-b) = a - (+b) = a - b = -1;
z5 = a +- b = a + (-b) = a - b = -1;
  • 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-13T13:31:58+00:00Added an answer on May 13, 2026 at 1:31 pm

    z = 3
    z1 = -1
    z2 = 3
    z4 = 3
    z5 = -1

    Without compiling, i’d say it’s a simple math operator combining
    I’ve learned it with this phrase (translated from Brazilian portuguese):

    Different signs = subtract
    Equal signs = add

    So

    int z = a + + + b; // '+' + '+' = '+' , the resulting '+' + '+' = + again.
    int z1 = a + - + b; // '+' + '-' = '-' , the resulting '-' + '+' = - again.
    int z2 = a + - - b; // '+' + '-' = '-' , the resulting '-' + '-' = +.
    int z3 = a - - + b; // '-' + '-' = '+' , the resulting '+' + '+' = + again.
    int z4 = a - - - b; // '-' + '-' = '+' , the resulting '+' + '-' = -.
    int z5 = a +- b; //simple "different signals = subtract" :)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just ran into a very interesting issue when someone posted a jsperf benchmark
I'm developing an Android application and I just ran into something. I have some
Just about everyone has ran into this specific issue: function addLinks () { for
I just upgraded to XCode 4.0.2 and ran into a strange issue. Every time
I just recently started learning and using the ADO.NET Entity Framework and ran into
I ran into a weird problem while trying to build a Traits GUI that
We ran into a bug in our product caused by the fact that for
I ran into this serialize gotcha today. From PHP.net doc: Note: Object's private members
I'm following the Rails Tutorial to get started (for the 4000th time) with Ruby
Here's the scenario, I have events happening from within an iframe and up until

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.