#include "test.h"
#include <math.h>
#include <stdint.h>
static struct {
double x,y;
} testdata[] = {
0x1.fffffffffffffp+1023, 0x1.fffffffffffffp+511,
0x1.ffffffffffffbp+1023, 0x1.ffffffffffffdp+511,
0x1.ffffffffffff7p+1023, 0x1.ffffffffffffbp+511,
0x1.ffffffffffff3p+1023, 0x1.ffffffffffff9p+511,
0x1.fffffffffffefp+1023, 0x1.ffffffffffff7p+511,
0x1.fffffffffffebp+1023, 0x1.ffffffffffff5p+511,
0x1.fffffffffffe7p+1023, 0x1.ffffffffffff3p+511,
0x1.fffffffffffe3p+1023, 0x1.ffffffffffff1p+511,
0x1.fffffffffffdfp+1023, 0x1.fffffffffffefp+511,
0x1.fffffffffffdbp+1023, 0x1.fffffffffffedp+511,
0x1.fffffffffffd7p+1023, 0x1.fffffffffffebp+511,
0x1.0000000000003p-1022, 0x1.0000000000001p-511,
0x1.0000000000007p-1022, 0x1.0000000000003p-511,
0x1.000000000000bp-1022, 0x1.0000000000005p-511,
0x1.000000000000fp-1022, 0x1.0000000000007p-511,
0x1.0000000000013p-1022, 0x1.0000000000009p-511,
0x1.0000000000017p-1022, 0x1.000000000000bp-511,
0x1.000000000001bp-1022, 0x1.000000000000dp-511,
0x1.000000000001fp-1022, 0x1.000000000000fp-511,
0x1.0000000000023p-1022, 0x1.0000000000011p-511,
0x1.0000000000027p-1022, 0x1.0000000000013p-511,
0x1.000000000002bp-1022, 0x1.0000000000015p-511,
0x1.000000000002fp-1022, 0x1.0000000000017p-511,
0x1.0000000000033p-1022, 0x1.0000000000019p-511,
0x1.0000000000037p-1022, 0x1.000000000001bp-511,
0x1.7167bc36eaa3bp+6, 0x1.3384c7db650cdp+3,
0x1.7570994273ad7p+6, 0x1.353186e89b8ffp+3,
0x1.7dae969442fe6p+6, 0x1.389640fb18b75p+3,
0x1.7f8444fcf67e5p+6, 0x1.395659e94669fp+3,
0x1.8364650e63a54p+6, 0x1.3aea9efe1a3d7p+3,
0x1.85bedd274edd8p+6, 0x1.3bdf20c867057p+3,
0x1.8609cf496ab77p+6, 0x1.3bfd7e14b5eabp+3,
0x1.873849c70a375p+6, 0x1.3c77ed341d27fp+3,
0x1.8919c962cbaaep+6, 0x1.3d3a7113ee82fp+3,
0x1.8de4493e22dc6p+6, 0x1.3f27d448220c3p+3,
0x1.924829a17a288p+6, 0x1.40e9552eec28fp+3,
0x1.92702cd992f12p+6, 0x1.40f94a6fdfddfp+3,
0x1.92b763a8311fdp+6, 0x1.4115af614695fp+3,
0x1.947da013c7293p+6, 0x1.41ca91102940fp+3,
0x1.9536091c494d2p+6, 0x1.4213e334c77adp+3,
0x1.61b04c6p-1019, 0x1.a98b88f18b46dp-510,
0x1.93789f1p-1018, 0x1.4162ae43d5821p-509,
0x1.a1989b4p-1018, 0x1.46f6736eb44bbp-509,
0x1.f93bc9p-1018, 0x1.67a36ec403bafp-509,
0x1.2f675e3p-1017, 0x1.8a22ab6dcfee1p-509,
0x1.a158508p-1017, 0x1.ce418a96cf589p-509,
0x1.cd31f078p-1017, 0x1.e5ef1c65dccebp-509,
0x1.33b43b08p-1016, 0x1.18a9f607e1701p-508,
0x1.6e66a858p-1016, 0x1.324402a00b45fp-508,
0x1.8661cbf8p-1016, 0x1.3c212046bfdffp-508,
0x1.bbb221b4p-1016, 0x1.510681b939931p-508,
0x1.c4942f3cp-1016, 0x1.5461e59227ab5p-508,
0x1.dbb258c8p-1016, 0x1.5cf7b0f78d3afp-508,
0x1.57103ea4p-1015, 0x1.a31ab946d340bp-508,
0x1.9b294f88p-1015, 0x1.cad197e28e85bp-508,
0x1.0000000000001p+0, 0x1p+0,
0x1.fffffffffffffp-1, 0x1.fffffffffffffp-1,
};
void test_sqrt(void)
{
int j;
double x, y, y0;
for (j = 0; j < sizeof testdata / sizeof *testdata; j++) {
x = testdata[j].x;
y = testdata[j].y;
y0 = sqrt(x);
if (y != y0)
error("sqrt(%a): wanted %a got %a\n", x, y, y0);
}
}
void bench_sqrt(int N)
{
int i;
double x;
volatile double y;
x = 0x1.23456p7;
for (i = 0; i < N; i++) {
y = sqrt(x);
x += 0.0000001;
}
}