473,668 Members | 2,366 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get correct percentage

Hello,

This is actually a general programming question but I don't know which
newsgroup best to put it so please pardon me.

I've always been looking for the best way to get an accurate percentage
statistics.

For example, in a election scenario:

Person A gets 33 votes
Person B gets 33 votes
Person C gets 34 votes
Person D gets 35 votes

Total votes = 33 + 33 + 34 + 35 = 135
Percent for A = 0.244.... = 0.24 = 24%
Percent for B = 0.244... = 0.24 = 24%
Percent for C = 0.251... = 0.25 = 25%
Percent for D = 0.259... = 0.26 = 26%

Then add up the percentage values: 24 + 24 + 25 + 26 = 99
(where it should be 100)
So, does anybody have a way to get around this problem? How should I
calculate the percentage for each person so that the percentage will add up
to 100 in the end?

Thanks for your help
Happy New Year
Conax
Jul 19 '05 #1
7 2808
What you are seeing is rounding error. You can reduce the effect by using
more precision:

Percent for A = 0.244 = 24.4%
Percent for B = 0.244 = 24.4%
....

If that is not good enough then you should add the same disclaimer that
pollsters use to the effect that the results will not necessarily add up to
100% due to rounding error.

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Conax" <Co******@hotma il.com> wrote in message
news:uo******** ******@TK2MSFTN GP09.phx.gbl...
Hello,

This is actually a general programming question but I don't know which
newsgroup best to put it so please pardon me.

I've always been looking for the best way to get an accurate percentage
statistics.

For example, in a election scenario:

Person A gets 33 votes
Person B gets 33 votes
Person C gets 34 votes
Person D gets 35 votes

Total votes = 33 + 33 + 34 + 35 = 135
Percent for A = 0.244.... = 0.24 = 24%
Percent for B = 0.244... = 0.24 = 24%
Percent for C = 0.251... = 0.25 = 25%
Percent for D = 0.259... = 0.26 = 26%

Then add up the percentage values: 24 + 24 + 25 + 26 = 99
(where it should be 100)
So, does anybody have a way to get around this problem? How should I
calculate the percentage for each person so that the percentage will add up to 100 in the end?

Thanks for your help
Happy New Year
Conax

Jul 19 '05 #2
I think your percentages are accurate, but you simply
have to decide exactly how accurate you want them. Then
it becomes a decision of when (or if) to round. Any time
you round you will have a margin of error + or - a
certain amount.

Say you have 3 items with equal percentages. They could
each be represented as any of the following:

33%
33.3%
33.33%
33.333%
etc...

The more numbers to the right of the decimal, the greater
your degree of accuraccy.

Sincerely,
Invotion Engineering Team
Advanced Microsoft Hosting Solutions
http://www.Invotion.com
-----Original Message-----
Hello,

This is actually a general programming question but I don't know whichnewsgroup best to put it so please pardon me.

I've always been looking for the best way to get an accurate percentagestatistics.

For example, in a election scenario:

Person A gets 33 votes
Person B gets 33 votes
Person C gets 34 votes
Person D gets 35 votes

Total votes = 33 + 33 + 34 + 35 = 135
Percent for A = 0.244.... = 0.24 = 24%
Percent for B = 0.244... = 0.24 = 24%
Percent for C = 0.251... = 0.25 = 25%
Percent for D = 0.259... = 0.26 = 26%

Then add up the percentage values: 24 + 24 + 25 + 26 = 99
(where it should be 100)
So, does anybody have a way to get around this problem? How should Icalculate the percentage for each person so that the percentage will add upto 100 in the end?

Thanks for your help
Happy New Year
Conax
.

Jul 19 '05 #3
Thanks for your replies Mark and Invotion.

I was hoping someone would have a logic to somehow display percentage
without decimal points and yet can add up to 100%. But I am probably asking
too much, and should live with what you have suggested.

Thanks again for your help!

Regards
Conax
Jul 19 '05 #4
You could determine the difference from 100% and arbitrarily increase or
decrease some of the individual values. I wouldn't, but you could.

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Conax" <Co******@hotma il.com> wrote in message
news:%2******** *******@TK2MSFT NGP09.phx.gbl.. .
Thanks for your replies Mark and Invotion.

I was hoping someone would have a logic to somehow display percentage
without decimal points and yet can add up to 100%. But I am probably asking too much, and should live with what you have suggested.

Thanks again for your help!

Regards
Conax

Jul 19 '05 #5

"Conax" <Co******@hotma il.com> wrote in message
news:%2******** *******@TK2MSFT NGP09.phx.gbl.. .
Thanks for your replies Mark and Invotion.

I was hoping someone would have a logic to somehow display percentage
without decimal points and yet can add up to 100%. But I am probably asking too much, and should live with what you have suggested.
[start sacarasm]
Yes, unfortunately none of have a suggestion for changing the laws of
mathametics. It's like asking to split up $3 between 2 people without using
cents.
[end sacarasm]

Don


Thanks again for your help!

Regards
Conax

Jul 19 '05 #6
"Don Verhagen" wrote:

Yes, unfortunately none of have a suggestion for changing
the laws of mathametics. It's like asking to split up $3
between 2 people without using cents.


Imagine the ramifications if you could do it...

Assuming i/j (or even 100*i/j) is an integer for each integer i and j, we
should be able to represent every rational number exactly (in binary as well
as in decimal). This, in turn, would imply a trivial solution to the
Discrete Log Problem, meaning we could trivially factor arbitrarily large
numbers. That would render RSA encryption (among other things, like
Diffie-Hellmann key exchanges) immediately obsolete.

Bye-bye public key encryption...
--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 19 '05 #7
"Don Verhagen" <ne**@southea st-florida.com> wrote in message
news:bt******** ****@ID-181477.news.uni-berlin.de...

"Conax" <Co******@hotma il.com> wrote in message
news:%2******** *******@TK2MSFT NGP09.phx.gbl.. .
Thanks for your replies Mark and Invotion.

I was hoping someone would have a logic to somehow display percentage
without decimal points and yet can add up to 100%. But I am probably asking
too much, and should live with what you have suggested.


[start sacarasm]
Yes, unfortunately none of have a suggestion for changing the laws of
mathametics. It's like asking to split up $3 between 2 people without

using cents.
[end sacarasm]


$3 between 2 people:

Person 1: $2
Person 2: $1
Person 3: $0

Poor person 3. ;)

Cheers!
Peter Foti
Jul 19 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
6954
by: Les Juby | last post by:
I am trying to adjust the window/table size of a website (www.worklaw.co.za) which has made use of DIV tags with its settings embedded in an CSS file. The client wants its width and height to adjust according to dynamic screen size, and I have been able to adjust the width to a percentage value which works fine. But if I try do the same with the height it shows some very strange results squashing the field to display about 3 lines.
0
2038
by: fake ID | last post by:
Since you can't search for these symbols used in asp.net "<%#" or '<%=' I thought i'd post this to make things a little easier to find. Potential search word combinations: -lessthan Percentage symbol hash -lessthan Percentage symbol hash -lessthan Percentage hash -lessthan Percent symbol hash -less than Percentage symbol hash -less than Percentage hash
1
1932
by: Shadow Lynx | last post by:
Consider this simple HTML: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 STRICT//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Strict kills my widths!</title> </head> <body> <table style="width:400px; table-layout:fixed;">
5
4366
by: James Conrad StJohn Foreman | last post by:
Have found http://www-128.ibm.com/developerworks/db2/library/techarticle/lyle/0110lyle.html which is quite helpful, but doesn't quite tell me what I want. I have a table, advertising_spend with two columns, date and spend. SELECT date, spend, sum(spend) over (order by date) as cumulative_spend FROM advertising_spend WHERE date BETWEEN '01.03.2006' AND '31.03.2006'
15
5395
by: Lennart | last post by:
Hi folks, I have created an animated image gallery in dhtml. It works fine in Internet Explorer. In Firefox, it only works if I ommit the DOCTYPE tag. The page is valid xhtml-strict but with a xhtml1-strict DOCTYPE, I get a dead script and dozens of error messages like "Error in parsing value in property 'width'. Declaration dropped." on Line 0. This page doesn't work in Firefox but is valid xhtml:...
6
28090
by: Hacking Bear | last post by:
Hi, I still don't quite fully understand how to handle mixing border/margin pixel width with percentage width. In the example below, I want to place side-by-side two DIV boxes inside a box. 1. Each box takes up 50% of the parent. 2. One of the box has a border width of 1px.
5
2192
by: mohammaditraders | last post by:
Question # 1 Write a program which consists of a class named Student, the class should consists of three data members Name, Ob_marks, Total_marks and two member functions Cal_percentage() which calculate the percentage of the student by the formula (Ob_marks * 100 )/Total_marks and Display() which show all information of the student. The class should also contain the default constructor which initializes all the data member of...
8
3044
Nathan H
by: Nathan H | last post by:
I am trying to write a query that will result in showing records that have a large percentage difference among fields in a table. For instance: Table field1.Item field2.account1 (percentage) field3.account2 (percentage) field4.account3 (percentage) etc...
1
2467
by: zufie | last post by:
I have used Sum(Abs()) to convert my neg. (-) values to pos. (+) values how can I obtain the correct percentage. For example, here is my expression from my query trying to calculate the correct percentage, in this case, 2/2+3 = .4*100 = 40%. Expr18: (((Abs(Sum()))/ (Abs(Sum()))+ (Abs(Sum()))))
0
8459
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8791
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7398
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6206
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5677
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4373
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2784
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2018
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1783
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.