0
(-7 + 2) * (-4)=20 and (-7 + 2) * (-4.0)=20.0how?
the default format is float then how it is showing 20 not 20.0
2 Respostas
0
there is a * operator wich operates on ints, and another one with float/doubles. 4.0 is double so the double * operator takes place.
0
Much language make an implicit conversion between operands.... Think about a moltiplication between i and d (where i its an integer and d its a double)... Then i*d= r make a result but that type its r? integer or double? If you want an integer PROBABLY you will get some data loss its better make an operation without data losing but if you want make a moltiplication between different data type you have to convert one. In our case "i" must be converted to double, make multiplication with "d" and we get double "r" result