MCPcopy Create free account
hub / github.com/numpy/numpy / npy_to_float

Function npy_to_float

numpy/core/src/multiarray/textreading/conversions.c:112–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110
111
112NPY_NO_EXPORT int
113npy_to_float(PyArray_Descr *descr,
114 const Py_UCS4 *str, const Py_UCS4 *end, char *dataptr,
115 parser_config *NPY_UNUSED(pconfig))
116{
117 double double_val;
118 const Py_UCS4 *p_end;
119 if (double_from_ucs4(str, end, true, &double_val, &p_end) < 0) {
120 return -1;
121 }
122 if (p_end != end) {
123 return -1;
124 }
125
126 float val = (float)double_val;
127 memcpy(dataptr, &val, sizeof(float));
128 if (!PyArray_ISNBO(descr->byteorder)) {
129 npy_bswap4_unaligned(dataptr);
130 }
131 return 0;
132}
133
134
135NPY_NO_EXPORT int

Callers

nothing calls this directly

Calls 2

double_from_ucs4Function · 0.85
npy_bswap4_unalignedFunction · 0.85

Tested by

no test coverage detected