dimanche 22 juillet 2018

Dealing with infinities in C++?

1) Could you please explain the following behavior in C++:

#include <iostream>    
int main() {
    int a;
    a = INT32_MAX;
    std::cout << a << " " << a + 10;
    return 0;
}

Result:

2147483647 -2147483639

2) What are the best practices of working with infinities in C++?

Aucun commentaire:

Enregistrer un commentaire