Mark Gritter (markgritter) wrote,
Mark Gritter
markgritter

I Make This Mistake Every Six Months or So

Why, in C and C-like languages, is binary '&' lower precedence than '=='?

Do programmers more often want to do bit operations on equality tests than want to perform equality tests on bit operations? Do we have to blame George Boole for this one, or is this a more recent decision?

Obviously having logical '&&' lower precedence than '==' makes sense. So is the rationale here that '&' and '&&' should be interchangeable (if there are no side effects)? But "a | b & c" is not interchangeable with "a | b && c".
Tags: programming
Subscribe
  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 9 comments