Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Numpy int8

  • int8
import numpy as np

a = np.array([127], 'int8')
print(a.dtype)   # int8
print(a)         # [127]

a[0] += 1        # [-128]
print(a)

a[0] -= 1        # [127]
print(a)

a[0] = 255
print(a)         # [-1]

a[0] += 1
print(a)         # [0]