[Bug 298260] [libm] fmaf() mishandled some subnormal input

From: <bugzilla-noreply_at_freebsd.org>
Date: Mon, 07 Sep 2026 06:01:39 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=298260

            Bug ID: 298260
           Summary: [libm] fmaf() mishandled some subnormal input
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: kargl@FreeBSD.org

/*
 * Bug pointed out by kib at 
 *
https://lists.freebsd.org/archives/freebsd-numerics/2026-September/000135.html
 *
 * fmaf does not handle some subnormal cases correctly.  The current
 * software implementation for fmaf() yields
 *
 * x*y+z=0x1.0002p-133
 *
 * which can be shown to be wrong via a call to the x86_64 fma instruction.
 *
 * The correct output to the following program is 
 *
 * x*y+z=0x1.0001p-133
 */
#include <math.h>
#include <stdio.h>

int
main(void)
{
   float x = -0x1.001p-81f, y = 0x1.ffe002p-70f, z = 0x1.0002p-133f;
   float res;

   res = fmaf(x, y, z);
   printf("x*y+z=%a\n", res);

   return (0);
}

-- 
You are receiving this mail because:
You are the assignee for the bug.