On 3 September 2010 16:50, Alan Sondheim <[email protected]> wrote:
>
> Hi James, excuse my ignorance, but what does this do?
>
> Thanks, Alan
>
It displays the following:
x:4 !x:0 !!x:1
(!x != x) == true
(!!x != x) == true
(!!x != !x) == true
x:2 !x:0 !!x:1
(!x != x) == true
(!!x != x) == true
(!!x != !x) == true
x:1 !x:0 !!x:1
(!x != x) == true
(!!x != x) == false
(!!x != !x) == true
translated:
(x) holds the value 4, (not x) gives the value 0, (not (not x)) gives
the value 1
therefor:
(not x does not equate with x) is true
(not (not x) does not equate with x) is true
(not (not x) does not equate with not x) is true
and so on.
hth ;-)
> On Fri, 3 Sep 2010, James Morris wrote:
>
>> /* double_bang_test.c */
>>
>> #include <stdio.h>
>>
>> int main(int argc, char** argv)
>> {
>> int x = 4;
>>
>> do
>> {
>> printf("x:%d !x:%d !!x:%d\n", x, !x, !!x);
>>
>> /*
>> printf("\t(!x == x) == %s\n", (!x == x) ? "true" :
>> "false" );
>> printf("\t(!!x == x) == %s\n", (!!x == x) ? "true" :
>> "false" );
>> printf("\t(!!x == !x) == %s\n", (!!x == !x) ? "true" :
>> "false" );
>> */
>>
>> printf("\t(!x != x) == %s\n", (!x != x) ? "true" :
>> "false" );
>> printf("\t(!!x != x) == %s\n", (!!x != x) ? "true" :
>> "false" );
>> printf("\t(!!x != !x) == %s\n", (!!x != !x) ? "true" :
>> "false" );
>>
>> putchar('\n');
>>
>> } while(x >>= 1);
>>
>>
>> return 0;
>> }
>>
>> /*
>>
>> --
>> _
>> : http://jwm-art.net/
>> -audio/image/text/code
>>
>> */
>> _______________________________________________
>> NetBehaviour mailing list
>> [email protected]
>> http://www.netbehaviour.org/mailman/listinfo/netbehaviour
>>
>>
>
>
> ==
> email archive: http://sondheim.rupamsunyata.org/
> webpage http://www.alansondheim.org
> music archive: http://www.espdisk.com/alansondheim/
> ==
> _______________________________________________
> NetBehaviour mailing list
> [email protected]
> http://www.netbehaviour.org/mailman/listinfo/netbehaviour
>
--
_
: http://jwm-art.net/
-audio/image/text/code
_______________________________________________
NetBehaviour mailing list
[email protected]
http://www.netbehaviour.org/mailman/listinfo/netbehaviour