c# - Why is my float automatically rounding and how do i get it to stop -
this question has answer here:
why float automatically rounding , how stop
float pagecount = 10/6; should 1.666 giving 1.0
your calculation being done in integer type since both operands of int type
cast or mark atleast 1 of operand float.
float pagecount = 10/6f; //6f specifying 6 float or
float pagecount = ((float) 10)/6; in current form, both operands of integer type , division results in integer value why 1 not 1.666
Comments
Post a Comment