+ 1
If give a value in int or float or double like double 10/3 then return the value 3.3 bt return 3 and same as float and int why?
4 ответов
+ 1
you try type conversion, for example;
double=x;
x = (double)10/3;
I hope i could help you
+ 1
If you used a variable of type double or float it would return it with its decimals. When using integer type variables c# truncates the answer of an equation so the entire back end after the decimal point is discarded.
0
If I understand your question you perform an integer division, resulting in another integer and thus truncating the fractional part. Try this to obtain the result as a real number:
double x = 10 / 3.0;
- 2
okkk thanku