Let's say I have a double d = 123456789
(I know that the double is always representing an integer). I am trying to print it using C++ so that exactly 123456789
is printed. Unfortunately, this is not the default behavior:
double d = 123456789;
cout << d << "\n";
output: 1.23457e+08
I discovered the following trick/cheat:
double d = 123456789;
cout << (long) d << "\n";
output: 123456789
Is this the way to do it, or is there a cleaner way using some output manipulators?