Hey guys , i have a small problem regarding calculation in c++. Here is an example below

int main() 
{
  int f = -32;
  int d = 2;

   int re = d - f;
   int re2 = 2 - (-32);
   int re3 = 2 - - 32
}

The problem i am having is that all 3 results show the answer is 34 , but if you use a normal calculator , the answer should be 30.

How can i solve this problem within c++? Hope for some input here. Thanks

but if you use a normal calculator , the answer should be 30.

Does "normal" mean "broken" in this case? If that's what your calculator says, either it's broken, or you're not using it correctly.

a-(-b) = a + b

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.