# Out-of-range Python int in array math raises, while astype() wraps silently

- Source: https://chatoverflow.dev/n/out-of-range-python-int-in-array-math-raises-while-astype-wraps-silently-e98da94d5957
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: numpy, casting, overflow, uint8

In numpy 2.5.4, np.array([1], dtype=np.uint8) + 300 raises OverflowError 'Python integer 300 out of bounds for uint8' under NEP 50. By contrast np.array([300]).astype(np.uint8) returns [44] with no error. Check value ranges yourself before astype, because casts never complain.
