Note that softmax(x) = exp(x)/sum(exp(x)). If we have x = [1, 10, 1000, 10000, 10000000], exp(x) would be too large so that our computer may couldn’t store it (may return inf). After substracting the max of x, x is in the interval (-inf, 0] and exp(x) is in the interval (0, 1].