public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Alejandro Colomar <alx.manpages@gmail.com>
To: mtk.manpages@gmail.com
Cc: Alejandro Colomar <alx.manpages@gmail.com>,
	linux-man@vger.kernel.org, libc-alpha@sourceware.org
Subject: [PATCH v2] MAX.3, MIN.3: New page (and link page) to document MAX() and MIN()
Date: Wed, 12 May 2021 22:56:16 +0200	[thread overview]
Message-ID: <20210512205615.19985-1-alx.manpages@gmail.com> (raw)
In-Reply-To: <20210512204311.19399-1-alx.manpages@gmail.com>

Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
---

v2:
	- Reword paragraph about fmax(3) and fmin(3) in DESCRIPTION.

 man3/MAX.3 | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 man3/MIN.3 |  1 +
 2 files changed, 86 insertions(+)
 create mode 100644 man3/MAX.3
 create mode 100644 man3/MIN.3

diff --git a/man3/MAX.3 b/man3/MAX.3
new file mode 100644
index 000000000..3d69e8ac2
--- /dev/null
+++ b/man3/MAX.3
@@ -0,0 +1,85 @@
+.\" Copyright (C) 2021 Alejandro Colomar <alx.manpages@gmail.com>
+.\"
+.\" %%%LICENSE_START(VERBATIM)
+.\" Permission is granted to make and distribute verbatim copies of this
+.\" manual provided the copyright notice and this permission notice are
+.\" preserved on all copies.
+.\"
+.\" Permission is granted to copy and distribute modified versions of this
+.\" manual under the conditions for verbatim copying, provided that the
+.\" entire resulting derived work is distributed under the terms of a
+.\" permission notice identical to this one.
+.\"
+.\" Since the Linux kernel and libraries are constantly changing, this
+.\" manual page may be incorrect or out-of-date.  The author(s) assume no
+.\" responsibility for errors or omissions, or for damages resulting from
+.\" the use of the information contained herein.  The author(s) may not
+.\" have taken the same level of care in the production of this manual,
+.\" which is licensed free of charge, as they might when working
+.\" professionally.
+.\"
+.\" Formatted or processed versions of this manual, if unaccompanied by
+.\" the source, must acknowledge the copyright and authors of this work.
+.\" %%%LICENSE_END
+.\"
+.TH MAX 3 2020-11-01 "Linux" "Linux Programmer's Manual"
+.SH NAME
+MAX, MIN \- maximum or minimum of two values
+.SH SYNOPSIS
+.nf
+.B #include <sys/param.h>
+.PP
+.BI MAX( a ", " b );
+.BI MIN( a ", " b );
+.fi
+.SH DESCRIPTION
+These macros return the maximum or minimum of
+.I a
+and
+.IR b .
+.PP
+If any of the arguments is of a floating-point type,
+you might prefer to use
+.BR fmax (3)
+or
+.BR fmin (3),
+which can handle NaN.
+.PP
+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.
+.SH RETURN VALUE
+These macros return the value of one of their arguments,
+according to their relationship.
+.SH ERRORS
+These macros may raise the "invalid" floating-point exception
+when any of the arguments is NaN.
+.SH CONFORMING TO
+These macros are present in glibc and the BSDs.
+.SH EXAMPLES
+.EX
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/param.h>
+
+int
+main(int argc, char *argv[])
+{
+    int a, b, x;
+
+    if (argc != 3) {
+        fprintf(stderr, "Usage: %s <num> <num>\en", argv[0]);
+        exit(EXIT_FAILURE);
+    }
+
+    a = atoi(argv[1]);
+    b = atoi(argv[2]);
+    x = MAX(a, b);
+    printf("MAX(%d, %d) is %d\en", a, b, x);
+
+    exit(EXIT_SUCCESS);
+}
+.EE
+.SH SEE ALSO
+.BR fmax (3),
+.BR fmin (3)
diff --git a/man3/MIN.3 b/man3/MIN.3
new file mode 100644
index 000000000..9938abda2
--- /dev/null
+++ b/man3/MIN.3
@@ -0,0 +1 @@
+.so man3/MAX.3
-- 
2.31.1


  reply	other threads:[~2021-05-12 20:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-12 20:43 [PATCH] " Alejandro Colomar
2021-05-12 20:56 ` Alejandro Colomar [this message]
2021-05-12 20:59   ` [PATCH v2] " Alejandro Colomar (man-pages)
2021-05-12 21:17 ` [PATCH] " Paul Eggert
2021-05-12 22:32   ` Alejandro Colomar (man-pages)
2021-05-12 22:39     ` Paul Eggert
2021-05-12 22:51       ` [PATCH v3] MAX.3, MIN.3: New pages " Alejandro Colomar
2021-06-12  8:35         ` Ping: " Alejandro Colomar (man-pages)
2021-06-20  2:39         ` Michael Kerrisk (man-pages)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210512205615.19985-1-alx.manpages@gmail.com \
    --to=alx.manpages@gmail.com \
    --cc=libc-alpha@sourceware.org \
    --cc=linux-man@vger.kernel.org \
    --cc=mtk.manpages@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).