How to compute equation that includes a^n / n! for large a and/or n? I'm trying to compute
$$e^{-a} \times \sum_{n=0}^N \frac{a^n}{n!}$$
where $e^{1}=2.7183$, N is an integer > 0, and a is a real value > 0. For example, N=a=1500. 
But for large n, the n! goes to infinity, and for large a, the numerator a^n goes to infinity. Can any tricks be applied to compute this? What about in the case of either a>n or a< n?
UPDATE
Based on @DavidK answer, could I get extra precision by taking the log of the expression? For example, the natural log of the above expression is: 
$$-a + log(\sum_{n=0}^N \frac{a^n}{n!})$$
then when I get a result from this expression, take its inverse natural log? If so, the problem boils down how to compute 
$$log(\sum_{n=0}^N \frac{a^n}{n!})$$
without overflow (any ideas?).
 A: Note that 
$\sum_{n=0}^N {a^n \over n!} = 1+ {a \over 1} (1+{a\over 2}(1+\cdots{a \over N-1}(1+ {a \over N}))\cdots))$.
A: For any real number $a$ and for any $N \geq 0$ the product 
$$e^{-a} \times \sum_{n=0}^N \frac{a^n}{n!},$$
that is, the ideal mathematical object that your computation is
apparently supposed to represent, is a positive real number.
For $N=0$ the value of the product is simply $e^{-a}$, but as you
add terms (that is, for larger and larger $N$) the product approaches $1$,
but is always at least a tiny bit smaller.
If you have used the expression exp(-a) in an attempt to represent $e^{-a}$,
and the result of that expression is zero, it is not possible to get the
correct result by computing the sum. That is, there is no number you
could set the sum equal to, which, when multiplied by zero,
would give you a result that is a positive number less than or equal to $1$.
So the difficulty occurs not because your computation of the sum overflows.
The difficulty occurs because your computation of $e^{-a}$ underflows.
If you use a floating-point representation capable of representing
$e^{-a}$ as a normalized non-zero value (that is, a value that may be very
small, but is sufficiently different from zero that the computer can
store it without losing too many digits of precision),
then the sum should not overflow when you try to compute it.

Edit: copper.hat's technique is a relatively well-known way to add up terms when each term is a known multiple of the previous one.
You may be able to use logarithms with an adaptation of that technique 
to make a reasonably accurate calculation of your desired product where
$e^{-a}$ would underflow.
Using the method without logarithms, you might compute a sequence of
values like this:
\begin{align}
x_0 &= \frac{a}{N} \\
x_1 &= \frac{a}{N - 1}(1 + x_0) \\
x_2 &= \frac{a}{N - 2}(1 + x_1) \\
    & \quad \vdots \\
x_i &= \frac{a}{N - i}(1 + x_{i-1}) \\
    & \quad \vdots \\
x_{N-1} &= \frac{a}{1}(1 + x_{N-2}) \\
x_N &= 1 + x_{N-1} \\
\end{align}
The problem is that for very large $a$, the sequence grows very quickly
near the end, and may overflow your chosen numeric type if you do this
in a typical programming language without special "large number" support.
So instead you can work with the sequence $y_0, \ldots, y_N$ defined by
$y_i = \log(x_i)$.
Assuming $\log$ is natural log, 
you can use the fact that $1 + x = x\left(1 + \frac 1x\right)$ to rewrite
\begin{align}
\log(x_i) &= \log\left(\frac{a}{N - i}(1 + x_{i-1})\right) \\
&= \log(a) - \log(N - i) + \log(x_{i-1}) + \log\left(1 + \frac 1{x_{i-1}}\right)
\end{align}
as
$$
y_i = \log(a) - \log(N - i) + y_{i-1} + \log(1 + \exp(-y_{i-1})).
$$
Let $y_0 = \log(a/N)$, use the formula above to compute $y_i$
for $i = 1, 2, \ldots, N - 1$, and finally let
$y_N = y_{N-1} + \log(1 + \exp(-y_{N-1})).$
At some point during this computatation, if $a$ and $N$ are both large
enough, $\exp(-y_{i-1})$ will underflow, with the result that
$\log(1 + \exp(-y_{i-1}))$ will evaluate to $0$ rather than to
its correct (but very small) value.
This is a bias toward underestimating the sum,
but since $\log(1 + \exp(-y_{i-1})) < \exp(-y_{i-1})$,
and since $\exp(-y_{i-1})$ will be tiny and (probably)
very rapidly decreasing at that point,
the bias may not be too much.
At the end, you can evaluate your product, using the fact that
$$y_N = \log\left(\sum_{n=0}^N \frac{a^n}{n!}\right).$$
A: From its definition,
you are guaranteed that,
if $a > 0$,
$e^{-a}  \sum_{n=0}^N \frac{a^n}{n!}
\le 1
$.
(If $a < 0$
and $|a|$ is large,
the sum will have catastrophic cancellation,
so there is a problem from the start.)
Therefore,
have your current expression
be of the form
$t_k
=e^{-m}s_k
$,
where 
$s_k
= \sum_{n=0}^k \frac{a^n}{n!}
$.
Initially,
$k=0$,
$m = 0$,
and
$s_k = 1
$.
Each time
$k$ is incremented,
and the new
$s_k$
and $t_k$
are computed,
check if
$t_k > 1
$.
If so,
increment $m$
until
$t_k
=e^{-m}s_k
\le 1
$.
Once $k = N$,
compare $m$ with $a$.
If
$m \ne a$,
multiply by
$e^{m-a}$.
This will guarantee that
you will never get overflows
(though
$\frac{a^n}{n!}$
might get small for
$n >> a$,
but that is another problem).
A problem with this
is that
the many multiplies by $\frac1{e}$
to get
$e^{-m}$
might cause roundoff error
to accumulate.
This can be alleviated
by techniques such as
precomputed tables for
$e^{-j}$.
