  Let $h(d)$ be the class number of indefinite binary quadratic forms of
discriminant $d$, and let $\varepsilon_d$ be the corresponding fundamental
unit. In this paper, we obtain an asymptotic formula for the $k$-th moment of
$h(d)$ over positive discriminants $d$ with $\varepsilon_d\leq x$, uniformly
for real numbers $k$ in the range $0<k\leq (\log x)^{1-o(1)}$. This improves
upon the work of Raulf, who obtained such an asymptotic for a fixed positive
integer $k$. We also investigate the distribution of large values of $h(d)$
when the $d$'s are ordered according to the size of their fundamental units
$\varepsilon_d$. In particular, we show that the tail of this distribution has
the same shape as that of class numbers of imaginary quadratic fields ordered
by the size of their discriminants. As an application of these results, we
prove that there are many positive discriminants $d$ with class number
$h(d)\geq (e^{\gamma}/3+o(1))\cdot\varepsilon_d (\log\log \varepsilon_d)/\log
\varepsilon_d$, a bound that we believe is best possible. We also obtain an
upper bound for $h(d)$ that is twice as large, assuming the generalized Riemann
hypothesis.
