5/100
is done in integer arithmetic, which yields 0 before conversion. Try
double variable = 5.0/100;
If 5
is in a variable x
(of integer type), then use:
variable = (double)x/100;
or
variable = ((double)x)/100;
to make the intent clear (thanks John!)
or
variable = x/100.0;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…