Solved

percentages

Posted on 2004-10-10
5
353 Views
Last Modified: 2010-04-05
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 =)
0
Comment
Question by:LMuadDIb
  • 2
  • 2
5 Comments
 
LVL 4

Accepted Solution

by:
brunomsilva earned 125 total points
Comment Utility
Hi LMuadDIb,

36/100 = 0.36 = 36%

to find the opposite, suppose the bar is 150 long and you want a line that has 10%, multiply 150 * 10% (0.1) = 15

Cheers!
0
 
LVL 4

Author Comment

by:LMuadDIb
Comment Utility
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?
0
 
LVL 4

Author Comment

by:LMuadDIb
Comment Utility
DOH!
I also figured out my error which was another DOH! ;)
thanx
0
 
LVL 5

Expert Comment

by:Hypoviax
Comment Utility
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

 
0
 
LVL 5

Expert Comment

by:Hypoviax
Comment Utility
I was a bit slow in typing my post!!!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video discusses moving either the default database or any database to a new volume.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now