Re: Example where Euphoria defaults on a boolean expression
- Posted by 1evan at sbcglobal.net Nov 23, 2002
- 634 views
Rom wrote: > > atom e, > > e = 2 -- what he asked for > f = 3 -- what you gave him > if (f = e) and not ( f != e) then print( 1, 1) > else print ( 1, 0) > end if > > object line > line = gets( 0) > > >The Euphoria program returns "0" ...... which is wrong! > >"not E and E" is unsolvable, neither true nor false. >Euphoria cannot handle this (like C and Pascal). > >Rom > In boolean logic, there are two possible states: True and False, 1 and 0. If E = 1(True) then not E = 0(False) 0 and X (either 1 or 0) is always 0(False) not E and E = 0 0 and 1 = 0 If E = 0(False) then not E = 1(True) not E and E = 0 1 and 0 = 0 (3 = 2) is 0(False) not (3 != 2) is 0(False) -- (3 != 2) is 1(True), not(1) is False(0) (3 = 2) and not(3 != 2) is 0(False) -- 0 and 0 is 0(False)