提交 98be442e 编写于 作者: S Szabolcs Nagy

math: fix logb(-0.0) in downward rounding mode

use -1/(x*x) instead of -1/(x+0) to return -inf, -0+0 is -0 in
downward rounding mode
上级 4cec31fc
#include "libm.h"
#include <math.h>
/*
special cases:
......@@ -12,6 +12,6 @@ double logb(double x)
if (!isfinite(x))
return x * x;
if (x == 0)
return -1/(x+0);
return -1/(x*x);
return ilogb(x);
}
#include "libm.h"
#include <math.h>
float logbf(float x)
{
if (!isfinite(x))
return x * x;
if (x == 0)
return -1/(x+0);
return -1/(x*x);
return ilogbf(x);
}
#include "libm.h"
#include <math.h>
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
long double logbl(long double x)
{
......@@ -10,7 +10,7 @@ long double logbl(long double x)
if (!isfinite(x))
return x * x;
if (x == 0)
return -1/(x+0);
return -1/(x*x);
return ilogbl(x);
}
#endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册