-3

I have some problems understanding some Pascal boolean expressions, and don't understand how chained or / and work.

  • Why does False or True and True = True?
  • Why does False or True and True or False = True?

As I can see it evaluates them from the right to the left, or there is something I'm missing?

Weather Vane
  • 33,872
  • 7
  • 36
  • 56
Matei
  • 1,783
  • 1
  • 14
  • 17
  • 2
    It wouldn't matter what the operator precedence was in these two expressions. They would always evaluate to these values. Why are you surprised? – user207421 Mar 24 '15 at 22:01

1 Answers1

2

See http://www.freepascal.org/docs-html/ref/refch12.html for operator precedence in Free Pascal.

As you can see, and has a higher precedence over or operator:

False or True and True = False or (True and True) = False or True = True
False or True and True or False = False or (True and True) or False = False or True or False = True or False = True
milleniumbug
  • 15,379
  • 3
  • 47
  • 71
  • The operator precedence in Pascal is defined by the *Pascal User Manual and Report,* Jensen and Wirth. Free Pascal isn't any different. As a matter of fact the precedence in these expressions doesn't affect the result. – user207421 Mar 24 '15 at 22:04