mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: Paul Zimmermann <Paul.Zimmermann@inria.fr>
Cc: Rich Felker <dalias@libc.org>,
	musl@lists.openwall.com, sibid@uvic.ca,
	christoph.lauter@christoph-lauter.org,
	Jean-Michel.Muller@ENS-LYON.FR
Subject: Re: [musl] correctly rounded mathematical functions
Date: Tue, 4 Jan 2022 22:12:02 +0100	[thread overview]
Message-ID: <20220104211202.GB1320090@port70.net> (raw)
In-Reply-To: <mwbl0roa63.fsf@tomate.loria.fr>

* Paul Zimmermann <Paul.Zimmermann@inria.fr> [2022-01-04 15:19:48 +0100]:
> > Is there a standalone version of the code where it can be read in full
> > not as a patch to glibc? Is the code being developed in such a way
> > that it's not potentially a derivative work of the glibc versions?
> 
> yes there are several standalone versions of the code (entries marked "full"
> on https://homepages.loria.fr/PZimmermann/CORE-MATH/).

i only looked at cr_asinf:

  float
  cr_asinf (float x)
  {
    /* deal here with NaN, +Inf and -Inf */

yeah that can be tricky and different across math libs.
(errno vs no errno, wrapper to handle special cases vs no wrapper etc)

to minimize branches you may want to merge it with the |x|>1 check below.

    double absx = fabsf (x), y;
    if (absx > 1)
      return sqrt (-1.0); /* NaN */
    ...

this reminds me that musl does not use compiler builtins at build time,
which means fabsf, sqrt are extern calls, which means this will not be
a leaf function (note: sqrt is not a tail call here because of the
implicit conversion, i think it should be sqrtf).

i prefer to tail call a function with descriptive name when handling
errors, but it does not always work out well: e.g. underflow can be
tricky if you want to ensure that an exact subnormal result does not
raise it (e.g. powf(2, -140)), but inexact does.

  reply	other threads:[~2022-01-04 21:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-03 13:07 Paul Zimmermann
2022-01-04  0:04 ` Damian McGuckin
2022-01-04  2:29 ` Rich Felker
2022-01-04 14:19   ` Paul Zimmermann
2022-01-04 21:12     ` Szabolcs Nagy [this message]
2022-01-06  8:55       ` Paul Zimmermann

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=20220104211202.GB1320090@port70.net \
    --to=nsz@port70.net \
    --cc=Jean-Michel.Muller@ENS-LYON.FR \
    --cc=Paul.Zimmermann@inria.fr \
    --cc=christoph.lauter@christoph-lauter.org \
    --cc=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    --cc=sibid@uvic.ca \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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).