When I run the code it outputs 1 even though temp is 10 but it doesn't output 1.1 right after. Then it does what it's supposed to from 1.2 to 4.9 but then it outputs 5 and but not 5.1, which it shouldn't. So what the hell is going on here?
#include <iostream>
using namespace std;
int main()
{
    cout << "Input how many you want to calculate:\n";
    int last;
    cin >> last;
    double power = 1.0;
    double real = 0.0;
    //cout << 0 << ". " << real << "\n";
    for (int pos = 0; pos <= last; ++pos)
    {
        if (power * 10.0 <= real)
        {
            power = power * 10.0;
            real = 0.0;
            real = real + 1.0 / power;
        }
        double temp = real * power;
        double next = real + (1.0 / power);
        cout << "temp is: " << temp << "\n";
        if (next < power && static_cast<int>(temp) % 10 == 0)
            cout << "hello\n";
        else
            cout << pos << ". " << real << "\n";
        real = real + 1.0 / power;
    }
    return 0;
}
 
    