mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <>
To: Paul Zimmermann <>
Cc: Rich Felker <>,,,,
Subject: Re: [musl] correctly rounded mathematical functions
Date: Tue, 4 Jan 2022 22:12:02 +0100	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

* Paul Zimmermann <> [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

i only looked at cr_asinf:

  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:

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

  git send-email \ \ \
    --cc=Jean-Michel.Muller@ENS-LYON.FR \ \ \ \ \ \

* 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

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