AtomSoft Well-Known Member Nov 19, 2009 #1 hey guys this should be simple math but heh havent been to school in so long. i know percentage for normal usage like 10% of 29 is 2.9 but what happens when 0 isnt the least? like if i have a number from 20 to 60 how do i do it? the lest is 20 (which is my 0) the most is 60(which is my 100) how do i calculate what 30 would be in percentage?
hey guys this should be simple math but heh havent been to school in so long. i know percentage for normal usage like 10% of 29 is 2.9 but what happens when 0 isnt the least? like if i have a number from 20 to 60 how do i do it? the lest is 20 (which is my 0) the most is 60(which is my 100) how do i calculate what 30 would be in percentage?
S smanches New Member Nov 19, 2009 #2 Take the difference between MIN and MAX. This is the range you apply the percentage to, then just add back in the MIN figure. So 50% of 20-60 = 50% of 40 = 20 + 20(min) = 40. So for your example, 20-60 = 40. 30 / 40 = .75 = 75% Last edited: Nov 19, 2009
Take the difference between MIN and MAX. This is the range you apply the percentage to, then just add back in the MIN figure. So 50% of 20-60 = 50% of 40 = 20 + 20(min) = 40. So for your example, 20-60 = 40. 30 / 40 = .75 = 75%
AtomSoft Well-Known Member Nov 19, 2009 #4 ok i have this now: Code: conPer = ((contrast / 40) * 100); should return a normal 2-3 digit number right?
ok i have this now: Code: conPer = ((contrast / 40) * 100); should return a normal 2-3 digit number right?
AtomSoft Well-Known Member Nov 19, 2009 #5 i got it heh like this: Code: contrast = 57; conPer = (((float)contrast-20) / 40) * 100; conPer2 = (unsigned char)conPer;
i got it heh like this: Code: contrast = 57; conPer = (((float)contrast-20) / 40) * 100; conPer2 = (unsigned char)conPer;