<feed xmlns='http://www.w3.org/2005/Atom'>
<title>musl/src/math, branch master</title>
<subtitle>musl - an implementation of the standard library for Linux-based systems</subtitle>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/'/>
<entry>
<title>math: fmaf rewrite</title>
<updated>2026-09-09T23:28:32+00:00</updated>
<author>
<name>Szabolcs Nagy</name>
<email>nsz@port70.net</email>
</author>
<published>2026-08-11T19:00:25+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=48a619cad667c26e868dbaa5e556c4f0280b86a2'/>
<id>48a619cad667c26e868dbaa5e556c4f0280b86a2</id>
<content type='text'>
the new code uses that for all real |x| in [0x1p-999,0x1p999]

  y = (float)x

is the same as

  r = (double)x
  t = x - r
  if (t!=0 &amp;&amp; r.bits%2==0)
    r.bits += (r&lt;0)==(t&lt;0) ? 1 : -1
  y = (float)r

in all rounding modes, with the same fenv effects.
this can be interpreted as a round to odd adjustment[1].
in fmaf t is computed with a fast2sum variant.

- optimized common case.
- implicit uflow handling instead of fenv calls.
- no fegetround check.
- no api calls on hf targets.
- fixed missed uflow on targets that signal it before rounding:
    fmaf(-0x1p-100f, 0x1p-100f, 0x1p-126f)
- removed freebsd code references and comments.
- fmaf.o code size vs before the halfway subnormal fix:
    x86_64: 514 -&gt; 210
    armhf:  304 -&gt; 156 (v7 thumb, no vfma op)
    arm:    400 -&gt; 348 (soft float, no fenv)

round to odd paper (suggested by Sergey Davidoff):
[1] S. Boldo et al., Emulation of a FMA and correctly-rounded sums:
    proved algorithms using rounding to odd, 2008
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
the new code uses that for all real |x| in [0x1p-999,0x1p999]

  y = (float)x

is the same as

  r = (double)x
  t = x - r
  if (t!=0 &amp;&amp; r.bits%2==0)
    r.bits += (r&lt;0)==(t&lt;0) ? 1 : -1
  y = (float)r

in all rounding modes, with the same fenv effects.
this can be interpreted as a round to odd adjustment[1].
in fmaf t is computed with a fast2sum variant.

- optimized common case.
- implicit uflow handling instead of fenv calls.
- no fegetround check.
- no api calls on hf targets.
- fixed missed uflow on targets that signal it before rounding:
    fmaf(-0x1p-100f, 0x1p-100f, 0x1p-126f)
- removed freebsd code references and comments.
- fmaf.o code size vs before the halfway subnormal fix:
    x86_64: 514 -&gt; 210
    armhf:  304 -&gt; 156 (v7 thumb, no vfma op)
    arm:    400 -&gt; 348 (soft float, no fenv)

round to odd paper (suggested by Sergey Davidoff):
[1] S. Boldo et al., Emulation of a FMA and correctly-rounded sums:
    proved algorithms using rounding to odd, 2008
</pre>
</div>
</content>
</entry>
<entry>
<title>math: fix fmaf subnormal double rounding</title>
<updated>2026-09-09T23:23:14+00:00</updated>
<author>
<name>Szabolcs Nagy</name>
<email>nsz@port70.net</email>
</author>
<published>2026-08-11T19:00:25+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=a97644025bad0fe2a25d2458769f922232880826'/>
<id>a97644025bad0fe2a25d2458769f922232880826</id>
<content type='text'>
inexact halfway cases were not handled correctly for subnormals

  fmaf(0x20201p-92f, 0x1fe01p-92f, 0x1p-130f)
  = (float)(0x1p-130 + 0x1.000000004p-150)

was rounded to 0x1.00001p-130 first in double precision, then to
0x1p-130 in the float subnormal range instead of 0x1.00002p-130.

this is a minimal fix of the halfway check.

Reported-by: Sergey Davidoff &lt;shnatsel@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
inexact halfway cases were not handled correctly for subnormals

  fmaf(0x20201p-92f, 0x1fe01p-92f, 0x1p-130f)
  = (float)(0x1p-130 + 0x1.000000004p-150)

was rounded to 0x1.00001p-130 first in double precision, then to
0x1p-130 in the float subnormal range instead of 0x1.00002p-130.

this is a minimal fix of the halfway check.

Reported-by: Sergey Davidoff &lt;shnatsel@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>math: fix expl on x86</title>
<updated>2026-09-08T18:10:16+00:00</updated>
<author>
<name>Szabolcs Nagy</name>
<email>nsz@port70.net</email>
</author>
<published>2026-08-26T06:18:57+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=27b485a276c97cbd3d60ec2a05deb8af2eee54a3'/>
<id>27b485a276c97cbd3d60ec2a05deb8af2eee54a3</id>
<content type='text'>
expl asm special cased |x|&gt;=16384 and used 2^trunc(x) then,
but this was wrong for x&lt;=-16384 when 2^trunc(x) doesn't
underflow to 0. fixed by bumping the threshold up to 32768.

Reported-by: Paul Zimmermann &lt;Paul.Zimmermann@inria.fr&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
expl asm special cased |x|&gt;=16384 and used 2^trunc(x) then,
but this was wrong for x&lt;=-16384 when 2^trunc(x) doesn't
underflow to 0. fixed by bumping the threshold up to 32768.

Reported-by: Paul Zimmermann &lt;Paul.Zimmermann@inria.fr&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>math: fix powl(x&lt;0,oddint) for some over/underflow cases</title>
<updated>2026-09-08T00:49:28+00:00</updated>
<author>
<name>Szabolcs Nagy</name>
<email>nsz@port70.net</email>
</author>
<published>2026-08-25T08:52:42+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=ec9daea2c3a95291841990e1e4d7211d510f298b'/>
<id>ec9daea2c3a95291841990e1e4d7211d510f298b</id>
<content type='text'>
when x&lt;0 and y is an odd int then powl is computed for -x first
then negated at the end. some overflow cases missed the negation:

  powl(-1.5, 50001)
  powl(-0.5, 50001)
  powl(-0x1p-16444L, -1)

returned inf, 0 and inf instead of the negated values.

Reported-by: Paul Zimmermann &lt;Paul.Zimmermann@inria.fr&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
when x&lt;0 and y is an odd int then powl is computed for -x first
then negated at the end. some overflow cases missed the negation:

  powl(-1.5, 50001)
  powl(-0.5, 50001)
  powl(-0x1p-16444L, -1)

returned inf, 0 and inf instead of the negated values.

Reported-by: Paul Zimmermann &lt;Paul.Zimmermann@inria.fr&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>math: make acoshf consistent with acosh</title>
<updated>2026-08-05T17:54:27+00:00</updated>
<author>
<name>Szabolcs Nagy</name>
<email>nsz@port70.net</email>
</author>
<published>2026-08-03T10:49:22+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=26c909bb642175a2450c3145fc3af7ecb82911af'/>
<id>26c909bb642175a2450c3145fc3af7ecb82911af</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>math: fix acosh for x&lt;0</title>
<updated>2026-08-05T17:53:23+00:00</updated>
<author>
<name>Szabolcs Nagy</name>
<email>nsz@port70.net</email>
</author>
<published>2026-08-03T06:41:28+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=3e80328d45b73604012b9b174f11e3ed632005ce'/>
<id>3e80328d45b73604012b9b174f11e3ed632005ce</id>
<content type='text'>
acosh(-0x1.8p15) returned -3.7534177368329567 instead of nan.

the same issue got fixed for acoshf and acoshl in commits
c4c38e6364323b6d83ba3428464e19987b981d7a and
6d10102709df4bc966d2846c1c45cd667e5048e5 here we follow the latter.

reported by Paul Zimmermann.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
acosh(-0x1.8p15) returned -3.7534177368329567 instead of nan.

the same issue got fixed for acoshf and acoshl in commits
c4c38e6364323b6d83ba3428464e19987b981d7a and
6d10102709df4bc966d2846c1c45cd667e5048e5 here we follow the latter.

reported by Paul Zimmermann.
</pre>
</div>
</content>
</entry>
<entry>
<title>math: include missing float.h in logbl</title>
<updated>2026-06-04T14:05:29+00:00</updated>
<author>
<name>Szabolcs Nagy</name>
<email>nsz@port70.net</email>
</author>
<published>2026-06-01T13:21:09+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=af839d4381156d480203448e17d1275c4a512bd6'/>
<id>af839d4381156d480203448e17d1275c4a512bd6</id>
<content type='text'>
LDBL_* macros were not defined in logbl.

the code happens to be correct without them, but when the long double
format matches double the intention was to tail call logb.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
LDBL_* macros were not defined in logbl.

the code happens to be correct without them, but when the long double
format matches double the intention was to tail call logb.
</pre>
</div>
</content>
</entry>
<entry>
<title>remove incorrect comment regarding powl exceptional cases</title>
<updated>2024-08-15T00:43:27+00:00</updated>
<author>
<name>Rich Felker</name>
<email>dalias@aerifal.cx</email>
</author>
<published>2024-08-15T00:43:27+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=ca4e632df42a41aaaf9445a0cfaa939d50a565b8'/>
<id>ca4e632df42a41aaaf9445a0cfaa939d50a565b8</id>
<content type='text'>
the comment does not match the required or actual behavior when x&lt;0
and y is not an integer. while it could be corrected, the role of
comments here is to tell about characteristics unique to the
implementation, not to restate the requirements of the standard, so
just removing it seems best.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
the comment does not match the required or actual behavior when x&lt;0
and y is not an integer. while it could be corrected, the role of
comments here is to tell about characteristics unique to the
implementation, not to restate the requirements of the standard, so
just removing it seems best.
</pre>
</div>
</content>
</entry>
<entry>
<title>math: fix fma(x,y,0) when x*y rounds to -0</title>
<updated>2024-03-14T14:04:42+00:00</updated>
<author>
<name>Szabolcs Nagy</name>
<email>nsz@port70.net</email>
</author>
<published>2024-03-13T23:57:15+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=9683bd62414604d3bd56cf6bd7be8f54aa31e7d3'/>
<id>9683bd62414604d3bd56cf6bd7be8f54aa31e7d3</id>
<content type='text'>
if x!=0, y!=0, z==0 then

  fma(x,y,z) == x*y

in all rounding modes, while adding z can ruin the sign of 0 if x*y
rounds to -0.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
if x!=0, y!=0, z==0 then

  fma(x,y,z) == x*y

in all rounding modes, while adding z can ruin the sign of 0 if x*y
rounds to -0.
</pre>
</div>
</content>
</entry>
<entry>
<title>riscv32: add fenv and math</title>
<updated>2024-02-29T21:36:55+00:00</updated>
<author>
<name>Stefan O'Rear</name>
<email>sorear@fastmail.com</email>
</author>
<published>2020-09-03T09:45:44+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=b4f7b2ca350ccaa6f58ecec72ac46b7aef22d1c3'/>
<id>b4f7b2ca350ccaa6f58ecec72ac46b7aef22d1c3</id>
<content type='text'>
These are identical to riscv64.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
These are identical to riscv64.
</pre>
</div>
</content>
</entry>
</feed>
