  Let $\pi, \pi'$ be tempered representations of an affine Hecke algebra with
positive parameters. We study their Euler--Poincar\'e pairing $EP (\pi,\pi')$,
the alternating sum of the dimensions of the Ext-groups. We show that $EP
(\pi,\pi')$ can be expressed in a simple formula involving an analytic R-group,
analogous to a formula of Arthur in the setting of reductive p-adic groups. Our
proof applies equally well to affine Hecke algebras and to reductive groups
over nonarchimedean local fields of arbitrary characteristic.
