Вообще так беспардонно приводить double к int не очень то правильно.
Я бы лучше сделал через строку, примерно так, только первую часть числа выпилить:
C++ |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| #include <algorithm>
#include <iterator>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>
int main()
{
double d = 3.12345678901234;
std::ostringstream oss;
oss << std::setprecision(9) << d;
std::string s = oss.str();
std::copy(s.begin(), s.end(), std::ostream_iterator<char>(std::cout, ", "));
std::cout << std::endl;
return 0;
} |
|