Log in

View Full Version : the modulus operator in Windriver C++


Ether
02-02-2011, 12:54
Would someone with ready access to Windriver C++ please run the following short program and post whether it returns "-179" or "+181" ?

void main (void) {
signed int err;
err=(-179)%360;
printf("err=%d",err);
}

The old C compiler I have here returns -179, but I am told that newer compilers return +181.

Thanks.

Ether
10-02-2011, 15:53
Page 82 of ISO/IEC 9899:TC3 (attached) shows that

(-179)%360 must be -179