NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

lib/58246: asinf gives ~2ulp error when it should give <1ulp



>Number:         58246
>Category:       lib
>Synopsis:       asinf gives ~2ulp error when it should give <1ulp
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat May 11 21:25:00 +0000 2024
>Originator:     Taylor R Campbell
>Release:        current, 10, 9, 8, ...
>Organization:
The NetBSD Foundasinf
>Environment:
>Description:
On amd64, asinf(0.5) gives 0x1.0c1528p-1, which is >2.1ulp away from the true answer pi/6.

Instead, it should give 0x1.0c1524p-1, which is <0.3ulp away from the true answer pi/6.
>How-To-Repeat:
#include <float.h>
#include <math.h>
#include <stdio.h>

volatile float f = 0.5;

int
main(void)
{
	printf("asinf(%a) = %a, expected %a\n", f, asinf(f), 0x1.0c1524p-1);
	printf("error ~ %f ulp, expected ~ %f ulp\n",
	    fabsf((M_PI/6 - asinf(f))/(M_PI/6))/FLT_EPSILON,
	    fabsf((M_PI/6 - 0x1.0c1524p-1)/(M_PI/6))/FLT_EPSILON);
	fflush(stdout);
	return ferror(stdout);
}

>Fix:
Yes, please!



Home | Main Index | Thread Index | Old Index