How to calculate the Fourier Transform of a constant?
Solution 1:
Your computation is incorrect, because the value of $e^{-j2\pi f t}$ oscillates around the unit circle in the complex plane as $t \to \pm \infty$ (it doesn't approach either $0$ or $\infty$), unless $f = 0$, in which case it is constantly equal to $1$.
Thus, if we average over all values of $t$, we get $0$ if $f \neq 0$ (all the oscillations in the different directions cancel out), while we get $\infty$ if $f = 0$. So we have a function which is zero at all $f \neq 0$ and infinite at $f = 0$, i.e. $\delta(f)$. If we take the initial constant to be $1/2$ instead of $1$, we get $\frac{1}{2} \delta(f)$, as you surmise.
(This is a slightly informal discussion. The correct mathematical formalism for handling $\delta(f)$ is the theory of distributions. It's quite likely that someone else will post an answer, or maybe a link, discussing this more formally correct approach.)
Solution 2:
The mistake that you are doing is you ignored the 'j' in the exponent. The $e^j$ when raised to infinity is not equal to zero or infinity because
$e^{ix} = \cos(x)+i\sin(x)$,
and the cosine and sine magnitudes never go to beyond 1.
So the $e^{jx}$, as $x$ tends to infinity is not zero or infinity, cause they are just sinusoidal waves with both imaginary and real component.
Now keeping that aside, when you integrate a sinusoidal wave over infinite period you get zero cause the +ve half cycle and -ve half cycle keep cancelling each other for every complete cycle. EXCEPT WHEN THE FREQUENCY IS ZERO that is, if
$\cos (fx)$ has the value of $f=0$
then the value will be a constant (in this case it is 1) over the whole period.
That's the reason why you find the dirac delta function in the answer.