### Bookstore

 Computer Math and Games in Pascal (preview) Lazarus Handbook

### Author Topic: How is "not condition1 and condition2" evaluated?  (Read 4185 times)

#### glorfin

• Jr. Member
• Posts: 80
##### Re: How is "not condition1 and condition2" evaluated?
« Reply #60 on: July 18, 2019, 03:52:47 pm »
The really significant difference between an arithmetic expression and a Boolean expression is that, in the case of an arithmetic expression it is normally necessary to fully evaluate it to determine the result.

Well, generally even for arithmetic it is not always necessary. Consider an expression: a*(b+c) where a = 0.

You don't have to evaluate b+c to know the result. But, while this is true for mathematics, compiler does not know beforehand what is a, hence cannot use this shortcut.

#### 440bx

• Hero Member
• Posts: 1925
##### Re: How is "not condition1 and condition2" evaluated?
« Reply #61 on: July 18, 2019, 04:31:30 pm »
Well, generally even for arithmetic it is not always necessary. Consider an expression: a*(b+c) where a = 0.
That's correct.  That's why I stated "it is normally necessary...".  In the expression you used, as you pointed out, if the compiler could reliably determine that a = 0 then it wouldn't have to evaluate the expression to know the result will be zero.
FPC v3.0.4 and Lazarus 1.8.2 on Windows 7 64bit.