0 votes
in C Plus Plus by

Why does “type demotion” does not exist instead of “type promotion”? Also, it would consume less space resource than by doing it from type promotion.? 

1 Answer

0 votes
by

Let’s take an example to understand it. 
Suppose 
double a=1.5; int b=10 and we want to calculate a+b 
By type demotion, float type a will convert to int. Therefore a=1 and a+b=1+10=11 but we know that correct answer is 11.5 which will only get by type promotion. So the conclusion is that by type demotion we will not get the correct answer.

Related questions

0 votes
asked Jan 12 in C Plus Plus by GeorgeBell
0 votes
asked Jan 12 in C Plus Plus by GeorgeBell
...