From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from zimbra.cs.ucla.edu (zimbra.cs.ucla.edu [131.179.128.68]) by sourceware.org (Postfix) with ESMTPS id 77E4A385380C for ; Wed, 12 May 2021 21:17:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 77E4A385380C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=cs.ucla.edu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=eggert@cs.ucla.edu Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id BA72716008C; Wed, 12 May 2021 14:17:55 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id BVLc-q9bsRrB; Wed, 12 May 2021 14:17:54 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id C1D1A160102; Wed, 12 May 2021 14:17:54 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id eHdQLb2BNHSO; Wed, 12 May 2021 14:17:54 -0700 (PDT) Received: from [192.168.1.9] (cpe-172-91-119-151.socal.res.rr.com [172.91.119.151]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 9503716008C; Wed, 12 May 2021 14:17:54 -0700 (PDT) To: Alejandro Colomar , mtk.manpages@gmail.com Cc: linux-man@vger.kernel.org, libc-alpha@sourceware.org References: <20210512204311.19399-1-alx.manpages@gmail.com> From: Paul Eggert Organization: UCLA Computer Science Department Subject: Re: [PATCH] MAX.3, MIN.3: New page (and link page) to document MAX() and MIN() Message-ID: Date: Wed, 12 May 2021 14:17:54 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20210512204311.19399-1-alx.manpages@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, NICE_REPLY_A, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 21:17:59 -0000 On 5/12/21 1:43 PM, Alejandro Colomar via Libc-alpha wrote: > +If any of the arguments is of a floating-point type, "any" -> "either" > +these macros shouldn't be used That's too strong. It's often OK to use MAX and MIN on floating point=20 arguments. > +The arguments may be evaluated more than once, > +and their types might be promoted to a common type > +if both arguments aren't of the same type. This is muddy. It should state clearly that even if A and B are both=20 integers, MAX (a, b) might not return their maximum. For example, on a=20 typical C platform today, MAX (-1, 2147483648) returns 4294967295 and=20 MIN (-1, 2147483648) returns 2147483648. Also, the man page shouldn't require the arguments to be evaluated at=20 least once. It's possible to implement MAX so that it sometimes doesn't=20 evaluate one argument, and the documentation shouldn't preclude such an=20 implementation. The man page should more specifically mention that although MIN and MAX=20 are defined on GNU platforms, other platforms define them=20 elsewhere or not at all. > +These macros return the value of one of their arguments, Unfortunately they don't necessarily do that, as shown in the MAX=20 example above. I suggest looking at the remarks about MAX and MIN that are made here,=20 and incorporating the useful parts of these remarks into the man page: https://git.savannah.gnu.org/cgit/gnulib.git/tree/lib/minmax.h