Float digitis
float is 7 digit. Isn't it? why out put print out 6 digit?
1 2 3 4 5 6 7 8
|
#include <iostream>
using namespace std;
int main() {
float a = 1.23456.7;
cout << a;
}
|
You can set the output precision to show more or less digits:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
#include <iostream>
#include <iomanip>
int main()
{
float a = 1.234567;
std::cout.precision(8);
std::cout << a << std::endl;
std::cout << std::setprecision(5) << a << std::endl;
return 0;
}
|
Topic archived. No new replies allowed.