bug-coreutils
[Top][All Lists]
Advanced

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

Re: [PATCH] df: new option: --total (-c) to produce grand total (in the


From: Jim Meyering
Subject: Re: [PATCH] df: new option: --total (-c) to produce grand total (in the same way as du)
Date: Tue, 02 Sep 2008 14:18:07 +0200

"James Youngman" <address@hidden> wrote:

> On Tue, Sep 2, 2008 at 12:06 PM, Jim Meyering <address@hidden> wrote:
>> Andreas Schwab <address@hidden> wrote:
>>> Jim Meyering <address@hidden> writes:
>>>> Kamil Dudka <address@hidden> wrote:
>>>>> +#define LOG_EQ(a,b) (((a)&&(b))||(!(a)&&!(b)))
>>>>
>>>> This can be written more simply as !((a) ^ (b))
>>>
>>> Only if the operands are already boolean, and then you can just use a == b.
>>
>> Oh.  Right.  To be general, it'd have to be like this,
>> but this is probably too obtuse unless you're comfortable
>> with the "!!" pseudo operator idiom:
>>
>> #define LOG_EQ(a, b) !((!!(a)) ^ (!!(b)))
>
> Why is it necessary anyway?   The result of ! is already guaranteed to
> be either 1 or 0.   Hence as Andreas said,
>
> #define LOG_EQ(a,b) (!(a) == !(b))

That looks best.  Thanks!




reply via email to

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