Alternative to log-sum-exponential trick Typically  $$z= \log \sum_{i} e^{a_{i}}=m+ \log \sum_{i} e^{a_{i}-m}$$ where  $m= \max(a_{i})$.
This is called the log-sum-exponential trick that helps in numerical stability
What can we do for numerical stability if we just have 
$$z=\sum_{i} e^{a_{i}}$$ and $a_{i}'s$ are very small or very large?
 A: Your post uses $z$ to represent two different things, so I'll write $S=\sum_i e^{a_i}$ for the sum of exponentials.
The reason for the effectiveness of the log-sum-exponential trick is that $S$ may be subject to floating overflow or floating underflow whereas $\log S$ is usually fine. To take advantage of the trick, you need to formulate your original problem so that you can work with $\log S$ instead of $S$ itself.
If you really need to compute $S$ itself, then $S$ has to be within the limits than can be represented in floating point arithmetic, and there is no getting around that.  This means that none of the individual $e^{a_i}$ values can be subject to floating overflow.
The best you can do in general is to (i) sort the $a_i$s from smallest to largest, (ii) compute $\log S$ using the log-sum trick and then (iii) exponentiate to get $S$. This will not help if $S$ is subject to overflow, but it can help with underflow if the individual $e^{a_i}$ values would all underflow but the total sum $S$ is within the representable range.
There are a few special cases where one do a little better. For example $e^a+e^{-a}$ is a scaling of $\cosh(a)$, and the limma package on Bioconductor has a 'logcosh' function.
