Link to home
Start Free TrialLog in
Avatar of LMuadDIb
LMuadDIbFlag for United States of America

asked on

percentages

hey all, my question is

to keep it simple, lets say you have a bar thats 100 hundred long, and you have a line on it thats 36 long, what percentage would that line be long?
and vice versa, if you knew the percentage the line should be... how long would the line be?

Im usually very good in math, but for some reason Im having probs with this LOL
thanks in advance =)
ASKER CERTIFIED SOLUTION
Avatar of brunomsilva
brunomsilva

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of LMuadDIb

ASKER

with a funtion I made I get an
[Error] misc.pas(22): Incompatible types: 'Integer' and 'Extended'

in delphi code, if you wanted a button to be 25% of the width of the form its sitting on, how would you code it?
DOH!
I also figured out my error which was another DOH! ;)
thanx
Expanding on brunomsilva,

__________________________________________________
Part A)
To calculate it in delphi:

Percentage:=(36 div 100) * 100; //will give you the percentage of 36

PartB)
The opposite (using brunomsilva example):

Length:=(150 * (10 div 100)); //will give you the length of 15

__________________________________________________

Similarly if we use straight variables so that it can be changed dynamically:
Part A)

var Percentage,linelength,barlength:Integer;
begin
       Percentage:=(LineLength div BarLength) * 100;
end;

Part B)

var Percentamount,Linelength,barlength:Integer;
begin
      LineLength:=(BarLength * (PercentAmount div 100));
end;
__________________________________________________

Regards,

Hypoviax

 
I was a bit slow in typing my post!!!