Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 23 Oct 2012 07:19:07 -0700
From:      perryh@pluto.rain.com
To:        kline@thought.org, olivier.nicole@cs.ait.ac.th
Cc:        freebsd-questions@freebsd.org
Subject:   Re: way way off topic
Message-ID:  <5086a75b.PlTC1pdjbP5atD0Y%perryh@pluto.rain.com>
In-Reply-To: <CA%2Bg%2BBvgaYY-nh9d89a7ytf9RAgMSjFNHPh3GzNqNG0xPFEX9BQ@mail.gmail.com>
References:  <20121023042007.GA14738@ethic.thought.org> <CA%2Bg%2BBvgaYY-nh9d89a7ytf9RAgMSjFNHPh3GzNqNG0xPFEX9BQ@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Olivier Nicole <olivier.nicole@cs.ait.ac.th> wrote:
> On Tue, Oct 23, 2012 at 11:20 AM, Gary Kline <kline@thought.org> wrote:
> > apologies up front for this math type quandary. I had it in
> > a std C program, but 3+ hours of grepping havent found it.
> > I would have bet my last cent that I had a summary Somewhere,
> > but cant find that either.
> >
> > here is the problem as best I can remember it.
> >
> >         let's say that john is 8 and his older friend, jim, is 22.
> >         how much older is exact percentage terms is jim?
>
> That should be 22/8=2.75
> Jim is 275% older than John

No, a subtraction is needed if we wish to use the term "older".
Suppose Jim were 9; the above approach would give 9/8 => 1.125
so Jim is 113% older than John, which is clearly wrong (although
one could correctly say in that case that John's age is 113% of
Jim's age).

I think the OP is probably looking for

  ((22 - 8) * 100 + (8/2)) / 8

which will give the answer directly as a correctly-rounded
integral percentage.  (For a fractional percentage, use floats
instead of ints and omit the (8/2) part -- but in that case
you probably also want to express the ages in something other
than whole years.)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5086a75b.PlTC1pdjbP5atD0Y%perryh>