Consider following code:

#include <iostream>

using namespace std;

int aaa(int a) {
    cout << a * 0.3 << endl;
    return a * 0.3;
}

int main()
{
    cout << aaa(35000);
}

It prints out:

10500
10499

Why output differs?

I have a workaround to use "return a * 3 / 10;" but I don't like it.

Edit:

Found that doing "return float(a * 0.3);" gives expected value;

c++
Edit
Report