From owner-freebsd-hackers@FreeBSD.ORG Fri Mar 25 21:56:40 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1331C106564A; Fri, 25 Mar 2011 21:56:40 +0000 (UTC) (envelope-from delphij@gmail.com) Received: from mail-iw0-f182.google.com (mail-iw0-f182.google.com [209.85.214.182]) by mx1.freebsd.org (Postfix) with ESMTP id BDEE98FC0C; Fri, 25 Mar 2011 21:56:39 +0000 (UTC) Received: by iwn33 with SMTP id 33so1871703iwn.13 for ; Fri, 25 Mar 2011 14:56:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=5dPbtWdrPVne85fZJZILh5tV9Igg5+Ube2IS2JzzonM=; b=jJqjw9MgZ3BJA51JokQRxhnkjpycjDmqj5zw/8D1caSF4cDKmM0YvIOKgNHNaEVZhx YQiZ89KAjoUQVpmzI0C8d2HBjr11vIG65hKXJkQa05jzDDB0xOnMvcMBCTIl9FJRO+4D /p+z6GL/dfnc1mpwxxPhS5zNhsbvB/U32qVIY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=V3Fg7DorikoNHB5plecQa0NqQBNtJQQ72KCacecNVosMaL2I7FdL7yrThPwV50TQjK vKTKuI3IwY5w1G80Od0EeiyjG63StYHPKPmjhue03hhqBLxmdZvwGrZ4F3Tykbt7/Pv8 moGNFNJi+3uWRv64cjNrJpWfwQX1bUm+I5V/4= MIME-Version: 1.0 Received: by 10.231.197.27 with SMTP id ei27mr1196649ibb.198.1301088786221; Fri, 25 Mar 2011 14:33:06 -0700 (PDT) Received: by 10.231.143.209 with HTTP; Fri, 25 Mar 2011 14:33:06 -0700 (PDT) In-Reply-To: <20110325195325.GA69264@freebsd.org> References: <20110325002115.GA323@freebsd.org> <20110325015508.GA14565@freebsd.org> <20110325024658.GA19544@freebsd.org> <336A9ACD-29BF-41C9-BC25-917CC1E4587D@bsdimp.com> <20110325195325.GA69264@freebsd.org> Date: Fri, 25 Mar 2011 14:33:06 -0700 Message-ID: From: Xin LI To: Alexander Best Content-Type: multipart/mixed; boundary=00032556582eec92cd049f555622 Cc: freebsd-hackers@freebsd.org Subject: Re: Switching to [KMGTPE]i prefixes? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Mar 2011 21:56:40 -0000 --00032556582eec92cd049f555622 Content-Type: text/plain; charset=UTF-8 FYI I have a patch and I have incorporated some of Alexander's idea. Difference: - Use of both HN_DIVISOR_1000 and HN_IEC_PREFIXES triggers an assertion. I think it doesn't make sense to return since this is an API violation and we should just tell the caller explicitly; - DIVISOR_1000 and !1000 cases use just same prefixes, so merge them while keeping divisor intact; - Make prefixes table consistently long. I have no strong opinion on this one, though, it's just what my original version used and I can change it to the way Alexander did if there is an advantage of doing that way. (Note, it seems that we use HN_ prefix for both 'scale' and 'flags', I have sorted them by value but HN_IEC_PREFIXES should really belong to the flags group). Cheers, -- Xin LI http://www.delphij.net --00032556582eec92cd049f555622 Content-Type: text/x-patch; charset=US-ASCII; name="humanize_number.c.diff" Content-Disposition: attachment; filename="humanize_number.c.diff" Content-Transfer-Encoding: base64 X-Attachment-Id: f_glpmfu710 SW5kZXg6IGh1bWFuaXplX251bWJlci5jCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIGh1bWFuaXplX251bWJlci5j CShyZXZpc2lvbiAyMjAwMDkpCisrKyBodW1hbml6ZV9udW1iZXIuYwkod29ya2luZyBjb3B5KQ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