Skip to content

Commit 0e97ae7

Browse files
committed
import math
1 parent 10b7964 commit 0e97ae7

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

quaddtype/numpy_quaddtype/src/casts.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,25 +203,20 @@ static inline int
203203
unicode_to_quad_convert(const Py_UCS4 *ucs4_str, npy_intp unicode_size_chars,
204204
QuadBackendType backend, quad_value *out_val)
205205
{
206-
// Convert UCS4 to Python Unicode object then to UTF-8 bytes
207-
// This is more robust than manual UCS4→char conversion
208206
PyObject *unicode_obj = PyUnicode_FromKindAndData(PyUnicode_4BYTE_KIND, ucs4_str, unicode_size_chars);
209207
if (unicode_obj == NULL) {
210208
return -1;
211209
}
212-
213-
// Convert to UTF-8 bytes
210+
214211
const char *utf8_str = PyUnicode_AsUTF8(unicode_obj);
215212
if (utf8_str == NULL) {
216213
Py_DECREF(unicode_obj);
217214
return -1;
218215
}
219216

220-
// Use locale-independent parser
221217
char *endptr;
222218
int err = NumPyOS_ascii_strtoq(utf8_str, backend, out_val, &endptr);
223219

224-
// Check for parse errors
225220
if (err < 0) {
226221
PyErr_Format(PyExc_ValueError,
227222
"could not convert string to QuadPrecision: np.str_('%s')", utf8_str);

quaddtype/numpy_quaddtype/src/utilities.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <stdlib.h>
22
#include <string.h>
33
#include <ctype.h>
4+
#include <math.h>
45
#include "utilities.h"
56
#include "constants.hpp"
67

0 commit comments

Comments
 (0)