linux-man.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alejandro Colomar <alx@kernel.org>
To: Jan Engelhardt <jengelh@inai.de>
Cc: linux-man@vger.kernel.org
Subject: Re: [PATCH 1/2] fmod.3: add note how to obtain modulus/LPR
Date: Fri, 28 Jul 2023 22:26:30 +0200	[thread overview]
Message-ID: <9a0c757e-b5e5-873c-a545-a8ea5e292394@kernel.org> (raw)
In-Reply-To: <20230724134902.77081-1-jengelh@inai.de>


[-- Attachment #1.1: Type: text/plain, Size: 1054 bytes --]

Hi Jan,

On 2023-07-24 15:49, Jan Engelhardt wrote:
> Signed-off-by: Jan Engelhardt <jengelh@inai.de>
> ---
>  man3/fmod.3 | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/man3/fmod.3 b/man3/fmod.3
> index ee2333fdc..a33b83eb5 100644
> --- a/man3/fmod.3
> +++ b/man3/fmod.3
> @@ -58,6 +58,9 @@ is the quotient of
>  /
>  .IR y ,
>  rounded toward zero to an integer.
> +.PP
> +To obtain the modulus, more specifically, the Least Positive Residue, the
> +expression "fmod(fmod(x, y) + y, y)" needs to be used.

There's a more readable way (and it's probably also more efficient):
<https://stackoverflow.com/a/2708900>

I think it would be interesting to have an example program that
shows both, and implements a function double lpr(double, double)
that uses the branchy implementation.

Thanks,
Alex

>  .SH RETURN VALUE
>  On success, these
>  functions return the value \fIx\fP\ \-\ \fIn\fP*\fIy\fP,

-- 
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  parent reply	other threads:[~2023-07-28 20:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-24 13:49 [PATCH 1/2] fmod.3: add note how to obtain modulus/LPR Jan Engelhardt
2023-07-24 13:49 ` [PATCH 2/2] fmod.3: add example section Jan Engelhardt
2023-07-28 20:26 ` Alejandro Colomar [this message]
2023-09-04 18:53   ` [PATCH v2 1/2] fmod.3: add note how to obtain modulus/LPR Jan Engelhardt
2023-09-04 18:53     ` [PATCH v2 2/2] fmod.3: add example section Jan Engelhardt
2023-09-13 16:00       ` Alejandro Colomar

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=9a0c757e-b5e5-873c-a545-a8ea5e292394@kernel.org \
    --to=alx@kernel.org \
    --cc=jengelh@inai.de \
    --cc=linux-man@vger.kernel.org \
    /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 NNTP newsgroup(s).