bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Use of !!


From: arnold
Subject: Use of !!
Date: Sat, 29 Jan 2022 12:02:13 -0700
User-agent: Heirloom mailx 12.5 7/5/10

Hi.

<pjfarley3@earthlink.net> wrote:

> Thanks for the enlightenment Arnold.
>
> So if I understand your explanation correctly,  the phrase -!!-""
> translates to this sequence of operations:
>
> 1.    -""     Minus the empty string, becomes -0 which is still just zero
> 2.    !0      Not 0 becomes 1
> 3.    !1      Not 1 becomes zero
> 4.    -0      Minus 0 which is still just 0
>
> So if I am understanding correctly, the phrase -!!-"" is just a convoluted
> way to say "zero"?

Exactly: 

        $ for i in nawk mawk mksawk "busybox awk" gawk
        > do echo === $i
        > $i 'BEGIN { printf("%d\n", (-!!-"")) }'
        > done
        === nawk
        0
        === mawk
        0
        === mksawk
        0
        === busybox awk
        0
        === gawk
        0

Arnold



reply via email to

[Prev in Thread] Current Thread [Next in Thread]