math - Convert a large int to a float between 0.0f and 1.0f -


i'm working on project have pane goes 0 500 on x , z, need convert coordinate (from 0 500) float in range of 0.0 1.0 in because required of functions i'm using.

i'm stuck on how take axis position (lets like, 3475x3475) , change in it's relative position on plane 0.0f 1.0f

(i've tried write in way programmer can understand, instead of using unity terminology. if you're unity programmer , better understand terminology tell me , i'll re-write it)

you can take number ranges 0 500 , divide 500, e.g. scaled_x = x / 500.0f. depending on language , type of x need divide either 500 or 500.0f. if using language has integer division c, , if x integer x / 500 0 unless x 500, if x/500.0f float between 0.0f , 1.0f (assuming x between 0 , 500 inclusively). of course assuming want linear mapping, e.g. 0 maps 0, 100 maps 0.2, 250 maps 0.5 , on.


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -