I am new to C++ but upon testing, C++ seems to cut off digits after the 6th in std::cout by default. To show a specific amount of digit after the decimal point, setprecision seems to do the trick. You have to import the iomanip library to use it.
#include <iostream>
#include <iomanip> // library required for setprecision
using namespace std;
int main() {
double r = 50.5;
double z = 2550.25128788;
cout << fixed << setprecision(10) << r * z << "\n";
return 0; //Output: 128787.6900379400
}
fixed forces fixed-point notation instead of something like an exponential answer.
setprecision(n) specifies n decimal places for the output.