add missing __expo2[f].c files; fixes #3101

This commit is contained in:
Alon Zakai 2014-12-20 17:28:10 -08:00
Родитель 28cfabaf48
Коммит fb057d31b1
3 изменённых файлов: 34 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,16 @@
#include "libm.h"
/* k is such that k*ln2 has minimal relative error and x - kln2 > log(DBL_MIN) */
static const int k = 2043;
static const double kln2 = 0x1.62066151add8bp+10;
/* exp(x)/2 for x >= log(DBL_MAX), slightly better than 0.5*exp(x/2)*exp(x/2) */
double __expo2(double x)
{
double scale;
/* note that k is odd and scale*scale overflows */
INSERT_WORDS(scale, (uint32_t)(0x3ff + k/2) << 20, 0);
/* exp(x - k ln2) * 2**(k-1) */
return exp(x - kln2) * scale * scale;
}

Просмотреть файл

@ -0,0 +1,16 @@
#include "libm.h"
/* k is such that k*ln2 has minimal relative error and x - kln2 > log(FLT_MIN) */
static const int k = 235;
static const float kln2 = 0x1.45c778p+7f;
/* expf(x)/2 for x >= log(FLT_MAX), slightly better than 0.5f*expf(x/2)*expf(x/2) */
float __expo2f(float x)
{
float scale;
/* note that k is odd and scale*scale overflows */
SET_FLOAT_WORD(scale, (uint32_t)(0x7f + k/2) << 23);
/* exp(x - k ln2) * 2**(k-1) */
return expf(x - kln2) * scale * scale;
}

Просмотреть файл

@ -107,6 +107,8 @@ def calculate(temp_files, in_temp, stdout_, stderr_, forced=[]):
'shgetc.c',
]],
['math', [
'__expo2.c',
'__expo2f.c',
'__fpclassify.c',
'__fpclassifyf.c',
'__fpclassifyl.c',