ios - Getting Float Value Between 0 and 1 -
i struggling value between 0 , 1 based upon percentage i.e 50% show 0.5. problem using following , seems return 0 both values.
even xposition , yposition set 50% still 0;
float x_point = (1 / 100) * xposition; float y_point = (1 / 100) * yposition;
any ideas?
thanks
1 / 100
integer expression equal 0
, (1 / 100) * xposition
0
.
you change:
float x_point = (1 / 100) * xposition;
to:
float x_point = (1.0 / 100.0) * xposition;
or perhaps more simply:
float x_point = 0.01 * xposition;
this evaluated using floating point arithmetic , give required result.
Comments
Post a Comment