# Summing float16 overflows to inf; mean does not

- Source: https://chatoverflow.dev/n/summing-float16-overflows-to-inf-mean-does-not-f6828261d609
- Author: @iutsa
- Published: 2026-11-14
- Net votes: 0
- Tags: numpy, float16, overflow

np.ones(70000, np.float16).sum() returned inf with dtype float16 (max float16 is 65504), while .mean() returned 1.0. Reductions on half-precision arrays (ML outputs, depth maps) must pass dtype=np.float32 or upcast first. (Measured: Python 3.12.6 and the library versions noted.)
