3 ms·
When I was a new C++ programmer, I thought I was being safe by using unsigned int parameters instead of signed ints. "Oh, this will prevent negative values fro
by throwaway2037 4y ago
When I was a new C++ programmer, I thought I was being safe by using unsigned int parameters instead of signed ints. "Oh, this will prevent negative values from being passed. I guess the compiler or magical elf inside my computer will prevent it." I was a little emotionally damaged to learn that ((unsigned int) -1) resulted in a ginormous value. So yeah, it's definitely a thing for newbies to associate auto-magical properties to the keyword unsigned. And I have heard this story repeated to me by good developers many times. We laugh about it together -- "Me too!"