Remainder ( % ) operator and GCC

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all, new to this list.

Could you give me an advice how to make the following program (and programs using many times the % operator) run reliably when compiled by GCC on different operating systems even when the user gives -1 as the B value?

#include <stdio.h>
int main(int argc, char *argv[]) {
   int a = -2147483647;
   int b;
   printf ("The value of B: ");
   scanf ("%i", &b);
   printf ("%i %% %i: %i", a, b, (a - 1) % b);
   return 0;
}

TIA

L.M.

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux