Skip to content
Merged
Changes from all commits
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
10 changes: 10 additions & 0 deletions bitstruct/c.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,15 @@ static void pack_float_16(struct bitstream_writer_t *self_p,
{
uint8_t buf[2];

#if PY_VERSION_HEX >= 0x030B00A7
PyFloat_Pack2(PyFloat_AsDouble(value_p),
(char*)&buf[0],
PY_BIG_ENDIAN);
#else
_PyFloat_Pack2(PyFloat_AsDouble(value_p),
&buf[0],
PY_BIG_ENDIAN);
#endif
bitstream_writer_write_bytes(self_p, &buf[0], sizeof(buf));
}

Expand All @@ -416,7 +422,11 @@ static PyObject *unpack_float_16(struct bitstream_reader_t *self_p,
double value;

bitstream_reader_read_bytes(self_p, &buf[0], sizeof(buf));
#if PY_VERSION_HEX >= 0x030B00A7
value = PyFloat_Unpack2((const char*)&buf[0], PY_BIG_ENDIAN);
#else
value = _PyFloat_Unpack2(&buf[0], PY_BIG_ENDIAN);
#endif

return (PyFloat_FromDouble(value));
}
Expand Down