**Abstract:** The relationship between modular forms and quadratic fields is exceedingly rich. For instance, the Hilbert class field of an imaginary quadratic field may be generated by adjoining to the quadratic field a special value of the modular *j*-invariant. This is the underlying reason why “Ramanujan’s constant” *e*^{π√ 163 } is close to an integer, and is related to the famous prime generating polynomial *n*^{2 }+*n* + 41.

The connection between class groups of real quadratic fields and invariants of the modular group is much less understood. In my talk I will discuss some of what is known in this direction and present some new results (joint with W. Duke) about the asymptotic distribution of integrals of the *j*-invariant that are associated to ideal classes in a real quadratic field. The proof brings together ideas from hyperbolic geometry, harmonic analysis, and analytic number theory.