As Johannes Kloos suggests, you can use the Taylor expansion. Here's the straightforward application; there may be better ones.
Let s = 0 and t = 1.
Start a loop with n = 1, incrementing by 1 each time.
Let t = t * x / n.
If t is sufficiently small, exit the loop.
Let s = s + (t - floor(t)).
If s > 1, let s = s - 1.
Return t.
Essentially all the rounding error comes from the t - floor(t). Some numerical analysis should give the maximum size of t and hence the number of significant digits in t - floor(t); this, in turn, gives an idea of what "sufficiently small" means.
1
Bumbble Comm
On
The Fractionalpart of $e^x$ is given by
$\text{frac}(e^x)=e^x-\lfloor e^x\rfloor.$
0
Bumbble Comm
On
Suppose $x$ is between $100$ and $101$. To compute even one significant figure for the fractional part of $e^x$, you will need to know $x$ accurate to about $44$ significant figures...
As Johannes Kloos suggests, you can use the Taylor expansion. Here's the straightforward application; there may be better ones.
Essentially all the rounding error comes from the t - floor(t). Some numerical analysis should give the maximum size of t and hence the number of significant digits in t - floor(t); this, in turn, gives an idea of what "sufficiently small" means.