[OE-core] libm accuracy, eglibc compared to glibc
Mats Kärrman
Mats.Karrman at tritech.se
Wed Mar 12 15:30:43 UTC 2014
Hi,
I face a problem with libm. With my Dora build the following assertion doesn't hold:
sqrt( pow( sqrt( 2.0 ), 4.0 ) ) == 2.0
1) With my old OE-classic / glibc-2.9 / PowerPC-hf it holds.
2) With my Debian desktop PC / glibc-2.17 / amd64 it holds.
3) With my new OE-core Dora / eglibc-2.18 / PowerPC-hf it doesn't hold.
Close enough one can think but the standardized test case I run requires the result to be 2.0.
A simple test program:
--------------------------------------------------------------------
#include <stdio.h>
#include <math.h>
int main(){
double two = 2.0;
double four = 4.0;
double s1 = sqrt(two);
printf("sqrt(%.20f) = %.20f\n", two, s1);
double p = pow(s1, four);
printf("pow(%.20f, %.20f) = %.20f\n", s1, four, p);
double s2 = sqrt(p);
printf("sqrt(%.20f) = %.20f\n", p, s2);
}
--------------------------------------------------------------------
results from 1 and 2 (identical):
sqrt(2.00000000000000000000) = 1.41421356237309514547
pow(1.41421356237309514547, 4.00000000000000000000) = 4.00000000000000088818
sqrt(4.00000000000000088818) = 2.00000000000000000000
results from 3:
sqrt(2.00000000000000000000) = 1.41421356237309492343
pow(1.41421356237309492343, 4.00000000000000000000) = 3.99999999999999866773
sqrt(3.99999999999999866773) = 1.99999999999999955591
Does anyone know if this is a known "feature" of eglibc or know any other reason
for this difference?
Best Regards,
Mats
More information about the Openembedded-core
mailing list