mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
Explicitly check for weird values after calling pow().
This commit is contained in:
parent
fb905c3ebf
commit
7fa52f84c7
1 changed files with 9 additions and 0 deletions
|
@ -37,6 +37,14 @@ extern int errno;
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
#ifdef HUGE_VAL
|
||||||
|
#define CHECK(x) if (errno != 0) ; \
|
||||||
|
else if (-HUGE_VAL <= (x) && (x) <= HUGE_VAL) ; \
|
||||||
|
else errno = ERANGE
|
||||||
|
#else
|
||||||
|
#define CHECK(x) /* Don't know how to check */
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef THINK_C
|
#ifndef THINK_C
|
||||||
extern double fmod PROTO((double, double));
|
extern double fmod PROTO((double, double));
|
||||||
extern double pow PROTO((double, double));
|
extern double pow PROTO((double, double));
|
||||||
|
@ -262,6 +270,7 @@ float_pow(v, w)
|
||||||
}
|
}
|
||||||
errno = 0;
|
errno = 0;
|
||||||
ix = pow(iv, iw);
|
ix = pow(iv, iw);
|
||||||
|
CHECK(ix);
|
||||||
if (errno != 0) {
|
if (errno != 0) {
|
||||||
/* XXX could it be another type of error? */
|
/* XXX could it be another type of error? */
|
||||||
err_errno(OverflowError);
|
err_errno(OverflowError);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue