79319007

Date: 2024-12-31 02:03:32
Score: 1.5
Natty:
Report link

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.

Reasons:
  • RegEx Blacklisted phrase (1.5): I am new
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Nori