Return the signed-magnitude interpretation of the binary representation of x.
(x)
| 1973 | |
| 1974 | |
| 1975 | def integer_repr(x): |
| 1976 | """Return the signed-magnitude interpretation of the binary representation |
| 1977 | of x.""" |
| 1978 | import numpy as np |
| 1979 | if x.dtype == np.float16: |
| 1980 | return _integer_repr(x, np.int16, np.int16(-2**15)) |
| 1981 | elif x.dtype == np.float32: |
| 1982 | return _integer_repr(x, np.int32, np.int32(-2**31)) |
| 1983 | elif x.dtype == np.float64: |
| 1984 | return _integer_repr(x, np.int64, np.int64(-2**63)) |
| 1985 | else: |
| 1986 | raise ValueError(f'Unsupported dtype {x.dtype}') |
| 1987 | |
| 1988 | |
| 1989 | @contextlib.contextmanager |
no test coverage detected
searching dependent graphs…