+ 2
How do i round off a decimal number to 3 significant figures??
6 Answers
+ 4
#include <iostream>
#include <iomanip>
int main(void) {
double d = 1/3.;
std::cout << std::fixed << std::setprecision(3) << d << std::endl;
return 0;
}
+ 3
%.3f
+ 3
double p = 1/2.;
printf("%.3lf\n", p);
+ 3
#include <iostream>
int main(void) {
float p = 33.33333f; std::cout.setf(std::ios_base::fixed, std::ios_base::floatfield); std::cout.precision(3);
std::cout << p;
}
0
so if my value=p how do is use it?
0
thks man