Inaccurate value when calculating with float

Asked

Viewed 36 times

2

Rest is giving 0.72998 and not 0.73 why?

using namespace std;

int main() {

    float num=576.73;
    int x=num;
    cout<<"x "<<x<<endl;
    cout<<"num "<<num<<endl;
    num=num-x;
    cout<<"resto "<<num<<endl;
    return 0;
}
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.