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

Mark Wiebe report at bugs.python.org
Tue Apr 5 00:03:59 CEST 2011


Mark Wiebe <mwwiebe at gmail.com> 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 understand what's going on.) Taking two halfs, doing a primitive arithmetic operation on them as floats, then rounding back to half is what Mark was referring to on the list.

In NumPy I also tried to err more towards accuracy and performance than having each intermediate be strictly half. The einsum function retains intermediate values as floats when operating on half, for example, and that's what I recommended in the documentation.

I'd also suggest adding some more to the test suite here to verify that ties are rounding to the nearest even properly. You can see some tests for this here:

https://github.com/numpy/numpy/blob/master/numpy/core/tests/test_half.py#L124

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11734>
_______________________________________


More information about the Python-bugs-list mailing list