I remarked two things:
- std::numeric_limits<float>::max()+(a small number)gives:- std::numeric_limits<float>::max().
- std::numeric_limits<float>::max()+(a large numberlike:- std::numeric_limits<float>::max()/3)gives inf.
Why this difference? Does 1 or 2 results in an OVERFLOW and thus to an undefined behavior?
Edit: Code for testing this:
1.
float d = std::numeric_limits<float>::max();
float q = d + 100;
cout << "q: " << q << endl;
2.
float d = std::numeric_limits<float>::max();
float q = d + (d/3);
cout << "q: " << q << endl;
 
     
     
    