From what I understand, comparing two different types, including a short
and a long
will still cause a conversion. I believe that a short
will be promoted to an int
. However, I can't seem to find a direct answer on comparing a short
to a long
.
For example:
Is it improper to compare a Uint32
to a Uint8
.
Is it improper to add a Uint32
to a Uint8
?
Uint32/Uint8 are shorthand typedefs in SDL for uint32_t
and uint8_t
, respectively.
EDIT:
I suppose I should be a bit more explicit on my overall question. I'm really wondering whether or not comparing or evaluating with two different types of int
s, that are the same signage (in the example case, unsigned
), but differ in the SIZE (uint8_t
and uint32_t
), is an improper thing to do.
Perhaps it is improper due to a implicit conversion. Perhaps it is improper because of a performance issue other than conversion. Maybe it is frowned upon because of some sort of readability issue I am unaware of.
In the comments two similar questions were linked, however they are comparing an int
to a long
. Which I believe is very similar, but doesn't an int
just take the form of whichever version is needed (uint8_t
, sint16_t
, etc.)?