From owner-freebsd-questions@FreeBSD.ORG Tue Oct 23 07:22:02 2012 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 127A5F37 for ; Tue, 23 Oct 2012 07:22:02 +0000 (UTC) (envelope-from perryh@pluto.rain.com) Received: from agora.rdrop.com (agora.rdrop.com [IPv6:2607:f678:1010::34]) by mx1.freebsd.org (Postfix) with ESMTP id DE0B48FC16 for ; Tue, 23 Oct 2012 07:22:01 +0000 (UTC) Received: from agora.rdrop.com (66@localhost [127.0.0.1]) by agora.rdrop.com (8.13.1/8.12.7) with ESMTP id q9N7LuuO001425 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 23 Oct 2012 00:21:56 -0700 (PDT) (envelope-from perryh@pluto.rain.com) Received: (from uucp@localhost) by agora.rdrop.com (8.13.1/8.14.2/Submit) with UUCP id q9N7LuBL001424; Tue, 23 Oct 2012 00:21:56 -0700 (PDT) (envelope-from perryh@pluto.rain.com) Received: from fbsd81 ([192.168.200.81]) by pluto.rain.com (4.1/SMI-4.1-pluto-M2060407) id AA03335; Tue, 23 Oct 12 00:19:30 PDT Date: Tue, 23 Oct 2012 07:19:07 -0700 From: perryh@pluto.rain.com To: kline@thought.org, olivier.nicole@cs.ait.ac.th Subject: Re: way way off topic Message-Id: <5086a75b.PlTC1pdjbP5atD0Y%perryh@pluto.rain.com> References: <20121023042007.GA14738@ethic.thought.org> In-Reply-To: User-Agent: nail 11.25 7/29/05 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Oct 2012 07:22:02 -0000 Olivier Nicole wrote: > On Tue, Oct 23, 2012 at 11:20 AM, Gary Kline 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.)