12-11-2022, 04:46 PM
@SMcNeill
sorry for my position aside.
In BASIC there are Logical operators or only Bitwise operators?
Playing with the binary version of a number it is all straight and right...
but there is the logic that not is only bits and bytes...
we can agree that it is orrible that in BASIC there are no value for TRUE and FALSE as values not in the same field of numbers (it doesn't matter if the number is expressed in binary, octal, decimal or hexadecimal basis)...
there is just a little difference between 1 AND 256 versus False AND True.
The first expression (1 AND 256) is a bitwise operation and it has been showed at high level by Steve.
The second expression (False AND True) is a logical operation, in it is no important if you use binary/octal/decimal/hexadecimal number or symbolic sign, all that is important is that the whole universe of possible values are True and False that are opposite.
Both if we express True = 0 and False <> 0 or True <>0 and False = 0 the table of truth in logic math is the same!
The bitwise logic follows the rules and the path showed by Steve.
The logical math follows the rules and the path of its field.
Here some references out of my IMHO:
https://en.wikipedia.org/wiki/Truth_table
https://en.wikipedia.org/wiki/Mathematical_logic
We pay the lackness of the logic type in BASIC. But we must not loose our mind in this misunderstandment confounding Bitwise and Logic operators.
We surrogate True and False with 2 variables or CONSTants giving False = 0 and True = not False, but our BASIC language returns us a -1 when it wants meaning True.
It is clear that this condition makes more confusion... we would expect that all that is not -1 is no true and all that is not 0 is no false.
In this situation our BASIC leave us in trouble. But if we love BASIC, we love it with all its defects! And not to hide its defects!
So we must pay more attention when we declare the substitutes of False and True to make logic conditions in choice operators!
Try to run my example test in the original EQV thread... you can see an unwilling result in the output... AND returns True only if both conditions are True, and clearly with its first parameter False (0) we get a True response... there is something bitwise and not logic in that behaviour!
Thanks for reading, talking and sharing.
sorry for my position aside.
In BASIC there are Logical operators or only Bitwise operators?
Playing with the binary version of a number it is all straight and right...
but there is the logic that not is only bits and bytes...
we can agree that it is orrible that in BASIC there are no value for TRUE and FALSE as values not in the same field of numbers (it doesn't matter if the number is expressed in binary, octal, decimal or hexadecimal basis)...
there is just a little difference between 1 AND 256 versus False AND True.
The first expression (1 AND 256) is a bitwise operation and it has been showed at high level by Steve.
The second expression (False AND True) is a logical operation, in it is no important if you use binary/octal/decimal/hexadecimal number or symbolic sign, all that is important is that the whole universe of possible values are True and False that are opposite.
Both if we express True = 0 and False <> 0 or True <>0 and False = 0 the table of truth in logic math is the same!
The bitwise logic follows the rules and the path showed by Steve.
The logical math follows the rules and the path of its field.
Here some references out of my IMHO:
https://en.wikipedia.org/wiki/Truth_table
https://en.wikipedia.org/wiki/Mathematical_logic
We pay the lackness of the logic type in BASIC. But we must not loose our mind in this misunderstandment confounding Bitwise and Logic operators.
We surrogate True and False with 2 variables or CONSTants giving False = 0 and True = not False, but our BASIC language returns us a -1 when it wants meaning True.
It is clear that this condition makes more confusion... we would expect that all that is not -1 is no true and all that is not 0 is no false.
In this situation our BASIC leave us in trouble. But if we love BASIC, we love it with all its defects! And not to hide its defects!
So we must pay more attention when we declare the substitutes of False and True to make logic conditions in choice operators!
Try to run my example test in the original EQV thread... you can see an unwilling result in the output... AND returns True only if both conditions are True, and clearly with its first parameter False (0) we get a True response... there is something bitwise and not logic in that behaviour!
Thanks for reading, talking and sharing.