I'm trying to compute $\lfloor e^x \rfloor$, where x is a 64-bit integer. The problem is that the result of the computation may be close to 2^64. In this range, 64-bit floating point numbers will be sparser than 64-bit integers, so it would be a bad idea to use something like the
exp library function in C, which returns a
double. Instead I'd like to use a method which computes the 64-bit integer result directly.
Is there a formula or well-conditioned algorithm for computing this floor value as an integer, without losing precision by going through floating point?