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

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -