In C++ is it bad to store always positive integer in signed integer?
For example, seconds since epoch in signed integer.
If it can only be a positive number it is good to store it in a unsigned int because that will force a compilation error when trying to assign a negative number and it allows you to have twice the size of the signed integer can store.
int: –2147483648 to 2147483647 uint: 0 to 4294967295
So is it bad to store a always positive number in a signed integer? No it's not bad. You allocate the same amount of bytes. Is it better to use uint? Probably yes.