It's well-known that $ e^{\pi \sqrt{d}} $ is almost an integer when $ d $ is taken to be one of the large Heegner numbers $ d = 43, 67, 163 $.
I'm interested to know what the history of this discovery was like. Specifically, did the "empirical discovery" of the almost-integer values of $ e^{\pi \sqrt d} $ come before or after the theory of complex multiplication was already well understood? In other words, was the discovery that $ e^{\pi \sqrt d} $ was almost an integer for some small values of $ d $ accidental or was it motivated by known properties of the $ j $-invariant?
On p. 138 of Ranjan Roy's Elliptic and Modular Functions from Gauss to Dedekind to Hecke, he writes that Hermite gave the $q$-expansion of the $j$-function (not using modern notation) and from this estimated $e^{\pi\sqrt{43}}$ and $e^{\pi\sqrt{163}}$ as being very close to integers.