[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Expression statements
- From: David Given <dg@...>
- Date: Mon, 16 Aug 2010 23:28:02 +0100
On 16/08/10 20:24, Jonathan Castello wrote:
[...]
> Very true, I was referring to the literal value of the keywords
> though. I recall that VB's 'true' has a value of -1, which is a little
> disturbing...
That was common in a lot of Basics; it allowed them to get away without
boolean operators, since NOT 0 == -1 and NOT -1 == 0. This meant that
AND, OR and EOR didn't short circuit, since they were ordinary logical
operators.
...of course, it also meant this:
LET x = 1
IF x THEN PRINT "x is true!"
IF NOT x THEN PRINT "x is false!"
...would apparently violate causality.
Interesting tip about C: The !! 'operator' will collapse a value down to
0 or 1.
void* p = return_some_pointer();
printf("%d\n", !!p);
I haven't found a use for the ~~ 'operator' yet.
--
┌─── dg@cowlark.com ───── http://www.cowlark.com ─────
│
│ "Home is where, when you have to go there, they have to take you in."
│ --- Cordelia Naismith
Attachment:
signature.asc
Description: OpenPGP digital signature