lets say I have a string of characters, (I am sure they are all letters)
I want to make an is_uppercase function, thus my goal in this exercise is to check if the 5 bit is a 0 or not... (adding 32 to any uppercase gives me a lowercase)
The above code seems to work, though in this case I do not have to do any operations on the number.Code:bool is_uppercase(std::string word) { BOOST_FOREACH(char c, word) { if(c & 32) { return false; } } return true; }
but If i needed to use the ~ operator on the number 32 it would have messed me up by making the number negative...
ive triedCode:if ( ~c | ~32) // yields incorrect resultbut it also leads me to -33 .. (which is wrong)Code:~(32u)
how would I express a number as 'unsigned' ?



LinkBack URL
About LinkBacks



