c++ - Does an odd number always return floor when divided with a remainder? -
can sure odd number in c++ should return floor of result when divided in such way there remainder or there exceptions this? mean:
int x = 5; x = x/2; cout<<x; //2
yes. can sure of in c++
iso/iec n3485(working draft) says in 5.6.4
the binary / operator yields quotient, , binary % operator yields remainder division of first expression second. if second operand of / or % 0 behavior undefined. integral operands / operator yields algebraic quotient fractional part discarded;81 if quotient a/b representable in type of result, (a/b)*b + a%b equal a; otherwise, behavior of both a/b , a%b undefined.
Comments
Post a Comment