As others commented in the post, it is undefined behavior so the compiler can take any action at this point to print any value, even zero or infinite.
In this specific case, the compiler is actually doing the bare minimum, or perhaps nothing. I reverse compiled your code with a union:
#include <cstdint>
#include <cstdio>
union DoubleUnion {
double dval;
uint32_t uval[2];
};
int main() {
DoubleUnion uv;
uv.dval = -9.2559592117432085e+61;
printf( "%g %08x %08x\n", uv.dval, uv.uval[0], uv.uval[1] );
return 0;
}
So basically I am placing a double and two 32-bit integers sharing the same space in memory. I then retrofit your printed number inside that double and check what the integers are. The result is this Compiler explorer link
Program stdout
-9.25596e+61 00000008 cccccccc
So basically the first 4 bytes are exactly what you input, an eight. The remaining 4 bytes are 0xcccccccc which is pretty much garbage, what was there after the integer, probably in the stack.
You can obtain the same result with the following (but incorrect) code:
#include <cstdint>
#include <cstdio>
int main() {
double value = -9.2559592117432085e+61;
uint32_t* ptr = (uint32_t*)&value;
printf( "%g %08x %08x\n", value, ptr[0], ptr[1] );
return 0;
}
Compiler explorer link
UPDATE I though you'd find interesting unpacking the double.
#include <cstdint>
#include <cstdio>
#include <cmath>
int main() {
struct [[gnu::packed]] Double {
uint64_t mantissa: 52;
uint32_t exponent: 11;
uint32_t sign: 1;
};
union DoubleUnion {
Double fields;
double value;
uint64_t uval;
};
DoubleUnion du;
du.value = -9.2559592117432085e+61;
printf( "Raw values: Double:%g Int:%16lx Sign:%d Exp2:%d Man:%ld\n",
du.value, du.uval, du.fields.sign, du.fields.exponent, du.fields.mantissa );
int64_t mantissa = int64_t(du.fields.mantissa) | (int64_t(1) << 52);
mantissa = (du.fields.sign) != 0 ? -mantissa : mantissa;
int32_t exponent = int32_t(du.fields.exponent) - 1075;
double dval = double( mantissa ) * pow(2,exponent);
printf("Parsed values: Mantissa:%ld Exponent(2):%d Double:%g\n", mantissa, exponent, dval );
return 0;
}
Godbolt link
This prints
Program stdout
Raw values: Double:-9.25596e+61 Int:cccccccc00000008 Sign:1 Exp2:1228 Man:3602876265922568
Parsed values: Mantissa:-8106475893293064 Exponent(2):153 Double:-9.25596e+61