#23564 - 2002-06-20 10:05 AM
Problem with operator not (unexpected evaluation of expression)
|
Manfred Ernst
Fresh Scripter
Registered: 2001-11-27
Posts: 10
|
Hello together,
I found a problem with the operator not:
? 1 and 0 --> 0 ? not 0 and not 1 --> 1 !!!!!!!!! ? (not 0) and (not 1) --> 0
Shouldn't the second and third example give the same result? The precedence of the operator "not" is higher than "and".
Is this a bug or am I wrong?
Bye Manfred Ernst
(MCA: complete subject) [ 20 June 2002, 10:55: Message edited by: MCA ]
|
|
Top
|
|
|
|
#23566 - 2002-06-20 10:54 AM
Re: Problem with operator not (unexpected evaluation of expression)
|
MCA
KiX Supporter
   
Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
|
Dear,
Lonkero, you are right it has to deal with the precendence and order of evaluation of operators
Following tabel is an extraction for C language. Language which Ruud is using for KiXtart.
code:
() [] not * / + - shift_left shift_right (bitwise operations) < <= > => = <> bitwise_and (bitwise operations) bitwise_exclusive_or (XOR) (bitwise operations) bitwise_inclusive_or (NOR) (bitwise operations) and or
They are evaluating from left to right. To be sure you doesn't have problems with evaluations use at the right place parenthesis. Your examples with parenthesis looks like: - ((1) and (0)) -> 0 - (not (0 and not (1))) -> 1 - (not 0) and (not 1) -> 0 greetings.
|
|
Top
|
|
|
|
#23568 - 2002-06-20 11:18 AM
Re: Problem with operator not (unexpected evaluation of expression)
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Lonkero, Are you sure? Just tried it:
code:
$x=1 and not 1 $x ? $x=not 0 and not 1 $x ?
And I got: quote: 0 0
Which is what I'd expect.
|
|
Top
|
|
|
|
#23570 - 2002-06-20 11:47 AM
Re: Problem with operator not (unexpected evaluation of expression)
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Lonkero, It's a bug.
code:
$x=not 0 and not 1 ? $x
Returns "0" under KiXtart 4.00, but "1" under KiXtart 4.10 RC3.
It looks like the precedence has changed, and "and" now has a higher precedence than "not".
|
|
Top
|
|
|
|
#23572 - 2002-06-20 11:54 AM
Re: Problem with operator not (unexpected evaluation of expression)
|
MCA
KiX Supporter
   
Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
|
Dear Manfred,
Which version was you using? You see it becomes an interesting issue. greetings
|
|
Top
|
|
|
|
#23573 - 2002-06-20 11:56 AM
Re: Problem with operator not (unexpected evaluation of expression)
|
MCA
KiX Supporter
   
Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
|
So it still not a final release. We think Howard has discover an individual problem. greetings.
|
|
Top
|
|
|
|
#23576 - 2002-06-20 01:39 PM
Re: Problem with operator not (unexpected evaluation of expression)
|
MCA
KiX Supporter
   
Registered: 2000-04-28
Posts: 5152
Loc: Netherlands, EU
|
Problem will be fixed in next release. See reported BUG topic. greetings.
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 811 anonymous users online.
|
|
|