Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newb Question

Status
Not open for further replies.

walks

Technical User
May 7, 2001
203
CA
Im just exploring the C++ language and had a quick question regarding the Modulus operator (%)

Why is this statement valid
7.6 * (5 % 2)

where as this isnt
7.6 * 5 % 2
 
you must respect "operator precedence",since * and % have same precedence...and () has higher precedence...
 
7.6 * 5 % 2 as well as (7.6 * 5) % 2 aren't valid because
the %-operators left operand is of type double.
(int)(7.6 * 5) % 2 however will do because it first does type-casting, then %.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top