12-11-2022, 06:24 PM
@Hi Pete
I am always fallen in love for this QB64pe community,
where I can talk, have good teacher, learn and expand my mind and my soul.
Yes I love BASIC, but there are so many dialects of it, only here I find so open persons to let me say, listen, try and learn from and with them.
That is fantastic!
Here my bitwise response to your question..
while we use values more than 2 opposite you are working at bitwise level... if you want to work at logical level you must define 2 only value in opposite condition and use them only . So comparison and other kind of operation must reduce the result to one of the 2 value used for logical operation....
in this sense False = 0 is OK, True = not False is good until in this logical universe we use only 0 for False and -1 for True
(as you can see with this code
print 0, not 0
)
as far away we go from this binary universe (universe of 2 items and not the universe of number with basis 2) as we get back so bad unwanted results .
the response in code to your example is this
Dim As _Unsigned _Byte a, b
a = 2
b = 4
Print a Eqv b, a = b
Print "Here the bitwise explanation! In logical math there are only TRUE and FALSE, no numbers"
Print String$(14, "0") + _Bin$(a)
Print String$(13, "0") + _Bin$(b)
Print _Bin$(-7)
as you can see it is a bitwise operation using EQV so the bits in the same position if they are the same you get 1 and if they are different you get 0.
But the compiler (interpreter) at the end translates the binary number to the decimal number... so you get a signed number -7 also if you have declared 2 unsigned byte numbers.
To logical operators you must pass logical values (T or F) so conditions that returns those logical values
for example
print NOT(a=b) EQV (a not b)
no sense to pass numbers in any basis (binary, octal etc) to LOGICAL operators.
If you want code in bitwise, please talk with expert of this like Steve or anyone else so ASM expert.
PS
JAVA is an universe that I would like explore... but I have 2 problems, the lack of time to use for, the fear to start a trip with no end.
I am always fallen in love for this QB64pe community,
where I can talk, have good teacher, learn and expand my mind and my soul.
Yes I love BASIC, but there are so many dialects of it, only here I find so open persons to let me say, listen, try and learn from and with them.
That is fantastic!
Here my bitwise response to your question..
while we use values more than 2 opposite you are working at bitwise level... if you want to work at logical level you must define 2 only value in opposite condition and use them only . So comparison and other kind of operation must reduce the result to one of the 2 value used for logical operation....
in this sense False = 0 is OK, True = not False is good until in this logical universe we use only 0 for False and -1 for True
(as you can see with this code
print 0, not 0
)
as far away we go from this binary universe (universe of 2 items and not the universe of number with basis 2) as we get back so bad unwanted results .
the response in code to your example is this
Dim As _Unsigned _Byte a, b
a = 2
b = 4
Print a Eqv b, a = b
Print "Here the bitwise explanation! In logical math there are only TRUE and FALSE, no numbers"
Print String$(14, "0") + _Bin$(a)
Print String$(13, "0") + _Bin$(b)
Print _Bin$(-7)
as you can see it is a bitwise operation using EQV so the bits in the same position if they are the same you get 1 and if they are different you get 0.
But the compiler (interpreter) at the end translates the binary number to the decimal number... so you get a signed number -7 also if you have declared 2 unsigned byte numbers.
To logical operators you must pass logical values (T or F) so conditions that returns those logical values
for example
print NOT(a=b) EQV (a not b)
no sense to pass numbers in any basis (binary, octal etc) to LOGICAL operators.
If you want code in bitwise, please talk with expert of this like Steve or anyone else so ASM expert.
PS
JAVA is an universe that I would like explore... but I have 2 problems, the lack of time to use for, the fear to start a trip with no end.