summaryrefslogtreecommitdiffstats
path: root/Objects/floatobject.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-02-23 17:16:23 (GMT)
committerGitHub <noreply@github.com>2022-02-23 17:16:23 (GMT)
commit9bbdde218005f552304d9954bb97e3f9185edded (patch)
tree2085d4399dfdcb03bbf9af4c7e5cf92bbdb55f43 /Objects/floatobject.c
parent375a56bd4015596c0cf44129c8842a1fe7199785 (diff)
downloadcpython-9bbdde218005f552304d9954bb97e3f9185edded.zip
cpython-9bbdde218005f552304d9954bb97e3f9185edded.tar.gz
cpython-9bbdde218005f552304d9954bb97e3f9185edded.tar.bz2
bpo-45412: Add _PY_SHORT_FLOAT_REPR macro (GH-31171)
Remove the HAVE_PY_SET_53BIT_PRECISION macro (moved to the internal C API). * Move HAVE_PY_SET_53BIT_PRECISION macro to pycore_pymath.h. * Replace PY_NO_SHORT_FLOAT_REPR macro with _PY_SHORT_FLOAT_REPR macro which is always defined. gcc -Wundef emits a warning when using _PY_SHORT_FLOAT_REPR but the macro is not defined, if pycore_pymath.h include was forgotten.
Diffstat (limited to 'Objects/floatobject.c')
-rw-r--r--Objects/floatobject.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/Objects/floatobject.c b/Objects/floatobject.c
index 79fbdab..64d4c3e 100644
--- a/Objects/floatobject.c
+++ b/Objects/floatobject.c
@@ -10,7 +10,7 @@
#include "pycore_interp.h" // _PyInterpreterState.float_state
#include "pycore_long.h" // _PyLong_GetOne()
#include "pycore_object.h" // _PyObject_Init()
-#include "pycore_pymath.h" // _Py_ADJUST_ERANGE1()
+#include "pycore_pymath.h" // _PY_SHORT_FLOAT_REPR
#include "pycore_pystate.h" // _PyInterpreterState_GET()
#include "pycore_structseq.h" // _PyStructSequence_FiniType()
@@ -932,7 +932,7 @@ float___ceil___impl(PyObject *self)
ndigits <= 323). Returns a Python float, or sets a Python error and
returns NULL on failure (OverflowError and memory errors are possible). */
-#ifndef PY_NO_SHORT_FLOAT_REPR
+#if _PY_SHORT_FLOAT_REPR == 1
/* version of double_round that uses the correctly-rounded string<->double
conversions from Python/dtoa.c */
@@ -989,7 +989,7 @@ double_round(double x, int ndigits) {
return result;
}
-#else /* PY_NO_SHORT_FLOAT_REPR */
+#else // _PY_SHORT_FLOAT_REPR == 0
/* fallback version, to be used when correctly rounded binary<->decimal
conversions aren't available */
@@ -1039,7 +1039,7 @@ double_round(double x, int ndigits) {
return PyFloat_FromDouble(z);
}
-#endif /* PY_NO_SHORT_FLOAT_REPR */
+#endif // _PY_SHORT_FLOAT_REPR == 0
/* round a Python float v to the closest multiple of 10**-ndigits */
@@ -2479,7 +2479,7 @@ _PyFloat_Unpack2(const unsigned char *p, int le)
f |= *p;
if (e == 0x1f) {
-#ifdef PY_NO_SHORT_FLOAT_REPR
+#if _PY_SHORT_FLOAT_REPR == 0
if (f == 0) {
/* Infinity */
return sign ? -Py_HUGE_VAL : Py_HUGE_VAL;
@@ -2494,9 +2494,9 @@ _PyFloat_Unpack2(const unsigned char *p, int le)
"can't unpack IEEE 754 NaN "
"on platform that does not support NaNs");
return -1;
-#endif /* #ifdef Py_NAN */
+#endif // !defined(Py_NAN)
}
-#else
+#else // _PY_SHORT_FLOAT_REPR == 1
if (f == 0) {
/* Infinity */
return _Py_dg_infinity(sign);
@@ -2505,7 +2505,7 @@ _PyFloat_Unpack2(const unsigned char *p, int le)
/* NaN */
return _Py_dg_stdnan(sign);
}
-#endif /* #ifdef PY_NO_SHORT_FLOAT_REPR */
+#endif // _PY_SHORT_FLOAT_REPR == 1
}
x = (double)f / 1024.0;