This is a curiosity question. I was working with a Boolean to keep track of some parts of my code. I had the Boolean, say track initialised to be false. Now when I change it somewhere else to true using integer constant like :
track = 1;
this is defined. I understand how this would work true being 1 and false being 0. But now when you I say
track = 500;
this is still defined. Reasonable since it's any value other than or greater than 0 meaning it's true. My confusion now is when I do
track = 2147483648
which is 1 greater than INT_MAX the behaviour is still defined as true. Even when I push it a bit further to 2147483649454788. But when I equate to 21474836494547845784578 it throws an error
error: integer constant is too large for its type [-Werror] _softExit = 21474836494547845784578; ^~~~~~~~~~~~~~~~~~~~~~~
Now this is just confusing. I'm pretty new to C++ so I'm not sure why or what any of this means. I know I could just use track = true; but I'm just curious.
Aucun commentaire:
Enregistrer un commentaire