Let $f$ be a binary quadratic form with integer coefficients and non-zero discriminant $D$. Suppose for simplicity that $D$ is a fundamental discriminant (which in particular implies that $f$ is primitive). We say that $f$ *represents a square mod* $D$ if for any $a$ representable by $f$ we have


$$a \equiv \square \pmod{p}$$


for each prime $p | D$. Note that this condition only depends on the $\text{GL}\_2(\mathbb{Z})$-equivalence class of $f$. We can thus say that the $\text{GL}\_2(\mathbb{Z})$-class of $f$, $[f]$, is a *square class* if for a prime $q$ representable by $f$ and co-prime to $D$ satisfies $q \equiv \square \pmod{p}$ for $p | D$, and if $D \equiv 0 \pmod{4}$ (respectively $8$), then $q \equiv 1 \pmod{4}$ (respectively $8$). By our earlier discussion, the choice of $q$ representable by $f$ does not matter. 


How are 'square classes' distributed in the ideal class group of $\mathcal{O} = \mathcal{O}\_{\mathbb{Q}(\sqrt{D})}$? Heuristically, for each (odd) prime $p | D$, half of the classes of the ideal class group should be square mod $p$ and the other half should not, so the number of square classes ought to be $h\_2(D) 2^{-\omega(D)}$ where $h\_2(D)$ is the class number of $\mathcal{O}$ and $\omega(n)$ denotes the number of prime divisors of $n$. 



Distribution of 'square classes' of binary quadratic forms
The standard definition for a form to belong to the principal genus of forms with fundamental discriminant $d$ is that the primes $p$ coprime to $d$ that
the form $Q$ represents satisfy $(d\_1/p) = \ldots = (d\_t/p)$, where 
$d =d\_1 \cdots d\_t$ is the factorization of $d$ into prime discriminants. In particular, $Q$ is allowed to represent primes $p \equiv \pm 1 \bmod 8$ if
$d\_1 = 8$ occurs in the factorization, and primes $p \equiv 1, 3 \bmod 8$ if $d\_1 = -8$ occurs (for example, $40 = 5 \cdot 8$ and $-40 = 5 \cdot (-8)$ are
factorizations into prime discriminants, $40 = -5 \cdot (-8)$ is not since $-5$ is not a discriminant).


Gauss's principal genus theorem states that a form is in the principal genus if and only if the equivalence classof $Q$ is a square in the class group. The genus of a form is the sign vector $((d\_1/p), \ldots, (d\_t/p))$,
and there are forms for every sign vectors whose entries have product $+1$.


