CTK Exchange
Front Page
Movie shortcuts
Personal info
Awards
Reciprocal links
Privacy Policy

Interactive Activities

Cut The Knot!
MSET99 Talk
Games & Puzzles
Arithmetic/Algebra
Geometry
Probability
Eye Opener
Analog Gadgets
Inventor's Paradox
Did you know?...
Proofs
Math as Language
Things Impossible
My Logo
Math Poll
Other Math sit's
Guest book
News sit's

Manifesto: what CTK is about |Store| Search CTK Buying a book is a commitment to learning Table of content Things you can find on CTK Chronology of updates Email to Cut The Knot

CTK Exchange

Subject: "rounding data"     Previous Topic | Next Topic
Printer-friendly copy     Email this topic to a friend    
Conferences The CTK Exchange College math Topic #11
Reading Topic #11
Chris Morris
Charter Member
Nov-01-00, 02:09 PM (EST)
Click to EMail Chris%20Morris Click to send private message to Chris%20Morris Click to add this user to your buddy list  
"rounding data"
 
   Dear Alexander,


Problem: To make all integer percentages add up to 100%

To calculate the percentages, I divide each number by the total of all the numbers (and multiply by 100). A this point of course they all add up to 100, however I need integer percentages, so my problem really occurs in the conversion from floating point numbers to integers.

Here is an example of my problem

If the percentages work out to be

10.2
30.65
28.55
30.6


These floting point numbers all add up to 100. The integer parts add up to 98. If I round the values ie( 10,31,29,31) they add up to 101.

One way I thought about doing it was to add up all the fraction parts in this case (0.2+0.65+0.55+0.6) = 2. Therefore the rounding process should generate an additional 2%, I could then order the fractional parts (0.2, 0.55, 0.6, 0.65) Starting at the right hand side I could round up 2 values and round the rest down.

ie
Round the last 2 numbers up


.65 rounds to 1 (add 1 to the integer part = 31)
.6 rounds to 1 (add 1 to the integer part = 31)

and now round the rest down

.55 rounds to 0 (add 0 to the integer part = 28)
.2 rounds to 0 (add 0 to the integer part = 10)

The percents then all add up to 100, (31+31+28+10) = 100

I was hoping there was a simpler approach...

TIA
Chris Morris

-----Original Message-----
From: Alexander Bogomolny <mailto:alexb@cut-the-knot.com>
Sent: 22 January 2000 13:08
To: chris@morris.net
Subject: Re: Form posted from Microsoft Internet Explorer.


How do you convert the numbers to percentages?


  Alert | IP Printer-friendly page | Edit | Reply | Reply With Quote | Top
alexb
Charter Member
672 posts
Nov-01-00, 02:12 PM (EST)
Click to EMail alexb Click to send private message to alexb Click to view user profileClick to add this user to your buddy list  
1. "RE: rounding data"
In response to message #0
 
   Chris, I can assure you that there is no simple solution to the problem. It is not mathematical at all and the solution must fit into the nature of your application. If the approach you presented works for you, just go ahead and use it without looking for a simpler one. There is none. There is no universal approach to squeezing information expressed by real numbers into an integer presentation.

All the best,
Alexander Bogomolny


  Alert | IP Printer-friendly page | Edit | Reply | Reply With Quote | Top

Conferences | Forums | Topics | Previous Topic | Next Topic

You may be curious to visit the old CTK Exchange archive.

|Front page| |Contents|

Copyright © 1996-2018 Alexander Bogomolny

[an error occurred while processing this directive]
 Advertise

New Books
Second editions of J. Conway's classic On Numbers And Games and the inimitable Winning Ways for Your Mathematical Plays