Return the signed-magnitude interpretation of the binary representation of x.
(x)
| 1699 | |
| 1700 | |
| 1701 | def integer_repr(x): |
| 1702 | """Return the signed-magnitude interpretation of the binary representation |
| 1703 | of x.""" |
| 1704 | import numpy as np |
| 1705 | if x.dtype == np.float16: |
| 1706 | return _integer_repr(x, np.int16, np.int16(-2**15)) |
| 1707 | elif x.dtype == np.float32: |
| 1708 | return _integer_repr(x, np.int32, np.int32(-2**31)) |
| 1709 | elif x.dtype == np.float64: |
| 1710 | return _integer_repr(x, np.int64, np.int64(-2**63)) |
| 1711 | else: |
| 1712 | raise ValueError(f'Unsupported dtype {x.dtype}') |
| 1713 | |
| 1714 | |
| 1715 | @contextlib.contextmanager |
no test coverage detected