Wouldn't 10% only work if the int was less than 100? I was thinking that you could probably convert the int to a char array and just grab the last character in the array. I'm relatively new to c++ so take what I say with a grain of salt but what I'm suggesting sounds more accurate.
Something like
Char Last[sizeof(int)]="" + int + ""
Char Result[1]=Last[sizeof(int)-1]
Probably not syntax error free but I'd imagine something like this would probably work.
Very interesting. Clearly I'm not that familiar with the % operator. I'm pretty good at math. Never had a reason to use % in this manner. But I guess you learn something everyday. That's why I came here. Lol I may never use it again in life but good to know.
The most common uses of % have faded behind all our containers and tools; the only thing I can think of off the top of my head that uses % in a practical example would be a circular buffer. Im sure others have ideas on that, but you will see it again.
jonnin was apparently thinking of (confusing it with) bitwise masking with &.
Clearly a brain fart since he obviously knows the difference!
But using & 0xF would actually be more efficient/appropriate in the hexadecimal case.