lundi 20 septembre 2021

Why the comparison result are not as expected?

Could you explain why the following code give these result?

#include <iostream>
int main()
{
    int x = -1;
    unsigned int y = 1;
    if (x > y)
        std::cout << "true";
    else
        std::cout << "false";
}

Output = true but why ?

Aucun commentaire:

Enregistrer un commentaire