c# - How to calculate value percentage value between two points -


this dumb question but..

i have 3 values example lets call them minx, currentx , maxx. im looking way calculate percentage of maxx currentx represents. e.g if maxx 50 , minx 40 , currentx 45 want 50% pretty basic problem im having when 1 or more of variables negative number.

any appreciated, let me know if didn't explain myself enough

(currentx - minx) / (maxx - minx) 

will give percentage, if you're using negative numbers (as long maxx > currentx > minx). make sure you're dealing doubles/floats, not ints. otherwise you'll need cast.


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -