Image

Imagebellyjabies wrote in Imagecpp

Sorry if I seem rather dim, but I've only just started programming in C++. The problem I'm having is how to round numbers to 2 decimal places.

I have a variable called breve, which I've defined in the main part of the programme, and used later on.

double breve=(480000/bpm);

...more coding...

cout << "You chose breve. At " << bpm << " bpm, a breve lasts for " << breve << " ms";

When I output the value stored in the variable breve, I want it to be rounded to 2 decimal places. I've spoken to someone about this and they have used the round command, as in round((calculation),2), but this isn't working in my programme, so I presume I'm going wrong somewhere. Any help would be very much appreciated. Thank you!