Monday, March 7, 2011

2.5 Arithmetic Operators

  • Binary arithmetic operators are: +, -, *, /
  • Integer division truncates any fractional part
  • Modulus operator: %
  • x % y produce the remainder when x is divided by y (zero when y divides x exactly)
  • The % modulus operator cannot be applied to float or double
  • The direction of truncation for / and the sign of the result for % are machine-dependent for negative operands 
  • Precedence (lowest first) : + -, * / %, unary + -
  • Arithmetic operators associate left to right

No comments:

Post a Comment