[issue11734] Add half-float (16-bit) support to struct module

2011-04-05 Thread Mark Wiebe
Mark Wiebe added the comment: Just a few small tweaks. I think you meant to subtract the second term here: +#('>e', b'\x80\x01', -2.0**-25 + 2.0**-35), # Rounds to minimum subnormal Isn't the "x < 0" part unnecessary? Maybe a comment explain

[issue11734] Add half-float (16-bit) support to struct module

2011-04-04 Thread Mark Wiebe
Mark Wiebe added the comment: There's no disagreement, since they're different cases. Taking an arbitrary double, rounding to float, then rounding to half definitely has double-rounding issues. (And I would recommend constructing an example to add to the test case to make sure you

[issue11734] Add half-float (16-bit) support to struct module

2011-04-04 Thread Mark Wiebe
Mark Wiebe added the comment: The patch currently assumes IEEE 754 with byte-order matching the integer type. I see that pyconfig.h defines three possible cases when IEEE 754 doubles are supported, DOUBLE_IS_LITTLE_ENDIAN_IEEE754, DOUBLE_IS_BIG_ENDIAN_IEEE754, and

[issue11734] Add half-float (16-bit) support to struct module

2011-04-01 Thread Mark Wiebe
Mark Wiebe added the comment: I think this won't work on Windows since there the 64-bit int is generally __int64. If you look at the long long and unsigned long long support in _struct.c you can see a better way to do this: "#ifdef HAVE_LONG_LONG" and "unsigned PY_LON

[issue11734] Add half-float (16-bit) support to struct module

2011-04-01 Thread Mark Wiebe
Mark Wiebe added the comment: Taking a look at the patch, I see you're using the single -> half conversion routine from NumPy. This has the double rounding problem when converting double -> float -> half, so it would be better to use the double -> half routine. I implement