Getting percent of height, vertical volume slider

ok I am having a brain fart right now and can't think straight. I've done this many times before.

I am making a vertical volume slider. The top of my slider track is at -80 and the bottom is -16. So my volume handle can slide between -80 and -16 on the Y axis.

-48 is basically 50%. I can't for the life of me figure out this percentage right now, can someone give me a little math help. I took math in summer school all 3 years of high school for a reason :P

Answers


max = -80
min = -16
so total points in range = 64
so 50% of total = 64 / 2 = 32

Now starts moving up from -16. You get -48 when you move 32 (50%) points up.

So the percent for any value v (in positive) in range 16 to 80 is:

percent = (v - 16) / 64 * 100

For this example: (48 - 16) / 64 * 100 = 50


Need Your Help

Using of Entity Framework T4 POCO

c# asp.net .net entity-framework

I have been using Linq-to-SQL for a while to get access to my database. But I have recently been told this way of doing was not the best one since it allows to mix the data access & business lo...

Stepping through a program using Eclipse IDE

c++ eclipse debugging ide step-into

How do I step through the program one line at time.