C

Asked • 06/10/19

Why is 0 < -0x80000000?

I have below a simple program: #include <stdio.h> #define INT32_MIN (-0x80000000) int main(void) {  long long bal = 0;    if(bal < INT32_MIN )  {   printf("Failed!!!");  }  else  {   printf("Success!!!");  }  return 0; }The condition `if(bal < INT32_MIN )` is always true. How is it possible?It works fine if I change the macro to: #define INT32_MIN (-2147483648L)Can anyone point out the issue?

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.