When we do this (0+3)/2…the answer we get is 1.
Why not c++ compiler approximate it to 2 ??
Is compiler performing typecasting??
And how approximation works in C++??
Please answer the questions seperately.
Doubt about approximation
hello @parth_tyagi
compilers are implemented like this only.
the result will depend on the type of NUmbers u are dealing with.
if anyone(numerator or denominator) of the number is double/float type then resultant will also be a double/float type.
If both operands are integers, the result is the integer portion of the quotient. For example, 17 / 3 is 5, with the fractional part discarded .