This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Increment and Decrement Operators

 
Saumya Tangeda
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I read about the rules for unary and binary numeric promotion.
Unary numeric promotion is valid for operators:+,-,~,[],<<,>>>,>>
Binary numeric promotion is valid for: -relational operators
-bitwise operators
- == and !=
-arithmetic operators
Does the type promotion occur for ++ and - - operators?What type?Unary or Binary?
 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it happens. Promotion and autocasting.

For instance:



This is equal to:



The ++ and -- operators act on a single operand, therefore the answer to your questions regarding if this is a binary or unary numeric promotion is evident.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic