Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
UPD commit msg: gh-101678: refactor the math module to use erf/erfc/l…
…og2 from c11
  • Loading branch information
skirpichev committed Feb 8, 2023
commit 538810dd92b95e8973b0c621a957741fa7d73d2f
21 changes: 1 addition & 20 deletions Modules/mathmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -641,27 +641,8 @@ m_log2(double x)
}
}

if (x > 0.0) {
#ifdef HAVE_LOG2
if (x > 0.0)
return log2(x);
#else
double m;
int e;
m = frexp(x, &e);
/* We want log2(m * 2**e) == log(m) / log(2) + e. Care is needed when
* x is just greater than 1.0: in that case e is 1, log(m) is negative,
* and we get significant cancellation error from the addition of
* log(m) / log(2) to e. The slight rewrite of the expression below
* avoids this problem.
*/
if (x >= 1.0) {
return log(2.0 * m) / log(2.0) + (e - 1);
}
else {
return log(m) / log(2.0) + e;
}
#endif
}
else if (x == 0.0) {
errno = EDOM;
return -Py_HUGE_VAL; /* log2(0) = -inf, divide-by-zero */
Expand Down