Can I convert log-odds ratios to log-probabilities without numeric stability issues? I have a bunch of log-odds ratios $\ell$
$$\ell = \log\left(\frac{p}{1 - p}\right)$$
where $p$ is unknown. I want to get $p$
$$p = \text{logistic}(\ell) = \frac{1}{1 + \exp(-\ell)},$$
but using this formula I have to evaluate $\exp(-\ell)$. When $\ell$ is very large in absolute value (and $p$ very small/very large), I might run into numerical stability issues on whatever platform I'm using. I'd ideally like $\log(p)$
$$
\log(p) = \log\left(\frac{1}{1 + \exp(-\ell)} \right) = \log(1) - \log(1 + \exp(-\ell)) = -\log(1 + \exp(-\ell))
$$
but it seems like I can't avoid evaluating $\exp(-\ell)$! Is there any hack to obtain $\log(p)$ from $\ell$ without running into potential numerical stability issues?
 A: Numerically, you'll have to deal with $\exp(-\ell)$ to some extent for a very simple reason: when $\ell$ is large, $\log p \approx -\exp(-\ell)$.
You definitely shouldn't compute $-\log(1 + \exp(-\ell))$, though: if $\ell$ is sufficiently large, $1 + \exp(-\ell)$ will just round off to $1$ and you get $\log p = 0$. But we have the inequality $\log (1 + x) \ge x(1-x)$ for $x>0$, and if $\ell$ is that large, then $1-x$ is $1$ to the degree that we can represent it at all: $x(1-x)$ and $x$ will have the same floating-point representations, and we can just set $\log p = - \exp(-\ell)$ with no trouble.
Of course, you need to worry about $-\log(1+\exp(-\ell))$ even when $\ell$ is large but not that large. You could deal with this case by using a Taylor series expansion, but this is a solved problem: most math libraries have a log1p command precisely for computing $\log(1+x)$ when $x$ is small. 
A: You say $p$ is very small by which I assume you mean $p$ is much smaller than $1$. 
As a first approximation, doesn't this suggest $1-p \approx 1$ so
$$\ell = \log{\frac{p}{1-p}} = \log{(p)}\, - \, \log{(1-p)} \approx \log(p)$$
