vector<double> vec;
for (double i = 1.0; i < 5.0; i += 0.2) vec.push_back(i);
for (auto x : vec) cout << x << "\t" << fmod(x, 1.0) << endl;
Wynik:
1 0
1.2 0.2
1.4 0.4
1.6 0.6
1.8 0.8
2 1
2.2 0.2
2.4 0.4
2.6 0.6
2.8 0.8
3 4.44089e-16
3.2 0.2
3.4 0.4
3.6 0.6
3.8 0.8
4 8.88178e-16
4.2 0.2
4.4 0.4
4.6 0.6
4.8 0.8