Basicprogramming(.org) > General questions and discussions
Basic Logic
Aurel:
Boolean is RESULT of comparison expression..
if we can call such a operation expression.
ZXDunny:
So you're saying that "=", "<=", "<>" etc should not return a numerical value, yes? So what should they return, and how should it be represented in memory? As something other than a value? If so, I have some very bad news for you.
Aurel:
If so, I have some very bad news for you.
What kind of bad news?
Paul
I just confirm what man above stated.
and that shouldn't be valid BASIC statement
print 1 > 2 -> show -1 (true)
what a heck is that in BASIC world...
Of course that i understand what that mean but is stupid..
should be ;( with more sense ..with boolean type )
print BOOL(1>2) -> -1
ZXDunny:
--- Quote from: Aurel on May 18, 2019, 07:13:24 PM --- If so, I have some very bad news for you.
What kind of bad news?
--- End quote ---
In computing, everything is a number. Including booleans.
--- Quote ---Paul
I just confirm what man above stated.
and that shouldn't be valid BASIC statement
print 1 > 2 -> show -1 (true)
what a heck is that in BASIC world...
Of course that i understand what that mean but is stupid..
should be ;( with more sense ..with boolean type )
print BOOL(1>2) -> -1
--- End quote ---
But a boolean is just a number - usually 1 or 0 for true or false (or in some dialects it's all bits set, so $FF if 8bit etc which yields -1 when viewed as a signed value) so the above statement is perfectly valid. But people who don't understand how a CPU works under the hood will often be surprised that 1<=x<=10 will always result in a true (non-zero) value.
I was puzzled that you said it shouldn't be valid BASIC. Why not?
Aurel:
Because is stupid and unlogical and as i show should be typed
As Boolean .
In computing, everything is a number. Including booleans.
Of course that i know that.. ::)
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version