Answer
$34.3$ years
Work Step by Step
Inflation: The amount A that ${{\$}} P$ can purchase after n years,
with annual inflation rate r (decimal) is $A=P\cdot(1-r)^{n}$
---
We want n for which
$A=0.5P, r=0.02$
$0.5P=P(1-0.02)^{n} \qquad.../\div P$
$0.5=(0.98)^{n} \qquad.../\log(..)$
$\log 0.5=n\log 0.98$
$n=\displaystyle \frac{\log 0.5}{\log 0.98}\approx 34.3$ years