Bug 10400

Summary: Bug in the double sqrt routine. Result should be corr. rounded according to the IEEE standard.
Product: [Retired] Red Hat Linux Reporter: shane.story
Component: glibcAssignee: Cristian Gafton <gafton>
Status: CLOSED NOTABUG QA Contact:
Severity: high Docs Contact:
Priority: medium    
Version: 6.0   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2000-03-28 23:32:32 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description shane.story 2000-03-28 22:59:35 UTC
#include <stdio.h>
#include <float.h>
#include <math.h>

double sqrt(double);

main()
{
double x, y, r;



*((int*)&x+1) = 0x3d2ffffe;
*(int*)&x = 0x7fffffff;

printf("x                %08X%08X %.16e \n\n", *(((int*)&x) + 1),
*((int*)&x
);

y = sqrt(x);

printf("result           %08X%08X %.16e \n", *(((int*)&y) + 1),
*((int*)&y),

*((int*)&r+1) = 0x3e8fffff;
*(int*)&r = 0x3ffffdbf;
printf("result should be %08X%08X %.16e \n", *(((int*)&r) + 1),
*((int*)&r),

}

It reports the following
x                      3D2FFFFE7FFFFFFF 5.6843378203226540e-14

result                3E8FFFFF3FFFFDC0 2.3841849383641896e-07
result should be 3E8FFFFF3FFFFDBF 2.3841849383641894e-07


The machine is running:


Red Hat Release 6.0 (hedwig)
Kernel 2.2.5-15smp on an i686

Comment 1 Cristian Gafton 2000-03-28 23:32:59 UTC
The representation is outside of the bounds of representation. 15 precision
digits is the most you can do on a double (well, that's what is guaranteed)