JOIN
 Select a Forum     Round Tables New Member Discussions News Discussions Algorithm Matches Marathon Matches NASA Tournament Lab TopCoder Cookbook High School Matches Sponsor Discussions Development Forums Design Forums Search | Watch Thread  |  My Post History  |  My Watches  |  User Settings View: Flat (newest first)  | Threaded  | Tree Previous Thread  |  Next Thread Forums Tutorial Discussions Representation of Integers and Reals Tutorial compiler optimization and associativity of operators
 compiler optimization and associativity of operators | Reply In the last rumor its mentioned"The other is that when optimizing your code the compiler is allowed to rearrange the order in which operations are computed ...As an example, the expression x + y - z may once be evaluated as x + (y - z) and the other time as (x + y) - z"Isnt this against what is defined by associativity of operators. My understanding is that, as + and - are operators of same precedence and left to right associativity the expression should always be evaluated as(x +y) - z;
 Re: compiler optimization and associativity of operators (response to post by gautam2roy) | Reply I don't understand. Does it make any diference?
 Re: compiler optimization and associativity of operators (response to post by gautam2roy) | Reply C#, for instance, guarantees the order of computation. operator precedence:Except for the assignment operators, all binary operators are left-associative, meaning that operations are performed from left to right. For example, x + y + z is evaluated as (x + y) + z.However, I'm not sure if c++ makes the same guarantee.
 Re: compiler optimization and associativity of operators (response to post by sjelkjd) | Reply On machines where overflows are reversible and do not cause exceptions, implementations are free to change the order of expression evaluation for built-in types taking advantage of associativity or commutativity (section 1.9.15)
 Re: compiler optimization and associativity of operators (response to post by Krzysan) | Reply thanks for that info!!
 Forums Tutorial Discussions Representation of Integers and Reals Tutorial compiler optimization and associativity of operators Previous Thread  |  Next Thread