bug-gawk
[Top][All Lists]
Advanced

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

Re: Slowness in bignum mode ( gmp | gawk -M ) when doubling extremely la


From: arnold
Subject: Re: Slowness in bignum mode ( gmp | gawk -M ) when doubling extremely large inputs
Date: Fri, 28 Jan 2022 01:46:19 -0700
User-agent: Heirloom mailx 12.5 7/5/10

<pjfarley3@earthlink.net> wrote:

> There are also several strange uses of the exclamation point operator
> (!) that I do not understand, but that is probably just my lack of
> experience.  Examples of such use are:
>
> _n1-!!_n1
> -!-""
> !+""
> !--_n10
>
> I THINK these are intended to be uses of the negation operator, but I
> don’t understand what that operation is supposed to do to an empty
> string.

Using ! converts non-zero to zero and zero to one, depending on the
value of the expression to which it is applied.

        !! <something>

converts <something> into a canonical truth value of 1 or 0. This can
occasionally be useful in C / C++ as well:

        const char *truth_value[] = { "false", "true" };

        printf("xyzzy is %s\n", truth_value[!! (some_expression)]);

Arnold



reply via email to

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