int a = 5 , b = 2 ;
double ans1 = a / b ; // ans1 = 2
cout << setprecision ( 4 ) << fixed << ans1 << endl ;
unsigned short int c = USHRT_MAX , d = USHRT_MAX ;
unsigned int ans2 = c + d ; // ans2 = 131070
cout << ans2 ;
What happens when the ( a / b ) is evaluated?
1) the result first stored in int ( variable type on the R.H.S ) and then converted into 64-bit double ( variable type on the L.H.S ) and then stored in the ans1 or first variables are converted into 64-bit double ( variable type on the L.H.S ) and then / takes place ?
2) if first evaluated as the variables type on R.H.S , then how the second one prints the correct ans ( because the ans is out of unsigned short int's limit )