  The derivative discontinuity of the exchange-correlation functional of
density-functional theory is cast as the difference of two types of electron
affinities. We show that standard Kohn-Sham calculations can be used to
calculate both affinities, and that their difference benefits from substantial
and systematic error cancellations, permitting reliable estimates of the
derivative discontinuity. Numerical calculations for atoms and molecules show
that the discontinuity is quite large (typically several eV), and significantly
and consistently improves the agreement of the calculated fundamental energy
gap with the experimental gaps. The percentage error of the single-particle gap
is reduced in favorable cases by more than one order of magnitude, and even in
unfavorable cases by about a factor of two.
