Cast int variable to double
If both of your variables are not double
s, assign them into a double
variable and then divide.
VarDouble = (double)int.....; VarDouble /= VarDouble1 etc
(double)rezultat /= value
I presume you are trying to make rezultat
a double
and I presume it's not declared as one and you just can't do that. Your resulting variable that will hold the result
must also be a double
or you will just get a whole number not rounded.
Convert.ToDouble(int);
http://msdn.microsoft.com/en-us/library/system.convert.todouble.aspx
(double)rezultat /= ...
is not good. The result of a casting expression is always an rvalue, i. e. something that cannot be assigned to. Related: you can't change the type of an expression (you can cast it, but that won't really change its type, just act as another type temporarily). Once you declared your variable as, say, an int
, you won't be able to store a double in it - however you cast the division, etc. it will always be truncated in the end.
You most likely have to introduce a double
temporary variable to store the result of the division.