Reputation: 34621
int main(int argc, char **argv)
{
unsigned char a = 10, b = 100;
std::cout<<sizeof(a-b)<<endl;
return 1;
}
Output: 4
What is the return data type?
Upvotes: 6
Views: 1929
Reputation: 355197
Arithmetic is always performed at least with int
precision in C++. a
and b
are both promoted to int
and the result of the subtraction is of type int
.
There are a set of rules used to determine the type used for an arithmetic operation; MSDN has a handy table listing the rules.
Upvotes: 9