Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3500264pxj; Mon, 7 Jun 2021 12:13:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWAI3lpnUOe5ntt6t91fXAjTvlAOlgGRvJG2HJMzrL3B6nPo2cDDMYuxsm9wSHm+AIu440 X-Received: by 2002:aa7:cb84:: with SMTP id r4mr21390174edt.187.1623093210026; Mon, 07 Jun 2021 12:13:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623093210; cv=none; d=google.com; s=arc-20160816; b=Dq2eB0GJdugmjWN0IU609qW3NdieOHv6M0fQEjLpPi6BLNjA0fBx2GKZfUQvxNmksn mC7/pb7JhL6wq4Qy71Y3/C+HvsmpPVrgL9d4gIJrGdpGOl4GFEppXdgZ1VS2+Hipvb+n KYdxLWqqfHvJSk013guBqGP2fsdeyRvVFE2HValaSoSBpHV9ED1puR3vRGlJeUeI/mci tBeaA3jkB4rbELrfL1xeAn6qf3w1oTVkGQQcOIyLKJf4jSzaUda/gaC8ohos3oynrMpP HjDAg+JcZXf1nCYi0vrVOb+a41YPKGR/uJQumxru6rwnV9VPdNSoMbhWo1T8CpFALinS NvDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=UPxONRgniJBC+KQvkkf0OJHJaOTulNwJ+SfnxYGVC1I=; b=gCIDCGLd2GNZdFOwb9entjHLV4oBIpp5NjK3dtLzPna1iF2R5cNz/bW6hHVc6JCker 1m0pCVB7JppgZkrbazfU5PRlRzu53mKAsMYC+YwxVBoUboOS/mtcxfS7+HQH3knoA2HT euJXXpVQ4ZBXbM5z2P4zqXUx1VEhXjgzpbMoZgDef4PD7J6oq4zrBC5IGii+6W6xvUKS zG9w0qWueW+uCdV5WbVxXhl0O+pFL0NEidsiv+mnCmwb0aIZNYz5AAFa/p8wdWYfzUva Ouw48mvXRSUf8I+0OVHNiI8/rZlet04xyjRqIvGR6no2jzbFoR/eHCuOkVURcTusaQKJ /XJg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i2si14964857ejp.119.2021.06.07.12.13.05; Mon, 07 Jun 2021 12:13:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231415AbhFGTLx (ORCPT + 99 others); Mon, 7 Jun 2021 15:11:53 -0400 Received: from smtprelay0022.hostedemail.com ([216.40.44.22]:38712 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230282AbhFGTLx (ORCPT ); Mon, 7 Jun 2021 15:11:53 -0400 Received: from omf13.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay08.hostedemail.com (Postfix) with ESMTP id CA628182CF66C; Mon, 7 Jun 2021 19:10:00 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf13.hostedemail.com (Postfix) with ESMTPA id B71321124F3; Mon, 7 Jun 2021 19:09:59 +0000 (UTC) Message-ID: Subject: Re: [PATCH v2 1/3] units: Add SI metric prefix definitions From: Joe Perches To: Andy Shevchenko , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jarkko Nikula , Mika Westerberg , wsa@kernel.org Date: Mon, 07 Jun 2021 12:09:58 -0700 In-Reply-To: <20210607152344.57458-1-andriy.shevchenko@linux.intel.com> References: <20210607152344.57458-1-andriy.shevchenko@linux.intel.com> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.38.1-1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.90 X-Stat-Signature: 8wbx163o9au6somidwb8kb4psryybbse X-Rspamd-Server: rspamout04 X-Rspamd-Queue-Id: B71321124F3 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX19gfuYGN0sZkfT6xaxuUJ3RaO+6FpeJDuo= X-HE-Tag: 1623092999-824842 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2021-06-07 at 18:23 +0300, Andy Shevchenko wrote: > Sometimes it's useful to have well-defined SI metric prefix to be used > to self-describe the formulas or equations. > > List most popular ones in the units.h. trivia: > diff --git a/include/linux/units.h b/include/linux/units.h [] > @@ -4,6 +4,22 @@ > ? > > ?#include > ? > +/* Metric prefixes in accordance with Syst?me international (d'unit?s) */ > +#define PETA 1000000000000000LL > +#define TERA 1000000000000LL > +#define GIGA 1000000000L > +#define MEGA 1000000L > +#define KILO 1000L It's perhaps more legible to avoid the long sequences of zeros by using preprocessor mechanisms. #define KILO (1000UL) #define MEGA (KILO * 1000) #define GIGA (MEGA * 1000) #define TERA (GIGA * 1000ULL) #define PETA (TERA * 1000) or maybe: #define KILO (1000UL) #define MEGA (1000UL * 1000UL) #define GIGA (1000UL * 1000UL * 1000UL) #define TERA (1000ULL * 1000ULL * 1000ULL * 1000ULL) #define PETA (1000ULL * 1000ULL * 1000ULL * 1000ULL * 1000ULL) etc... > +#define HECTO 100L > +#define DECA 10L Should it be DECA or DEKA or both? https://www.nist.gov/pml/weights-and-measures/metric-si-prefixes deka Example: dekameter da 10**1 Ten > +#define DECI 10L > +#define CENTI 100L > +#define MILLI 1000L > +#define MICRO 1000000L > +#define NANO 1000000000L > +#define PICO 1000000000000LL > +#define FEMTO 1000000000000000LL IMO: Might as well include all the prefixes up to 10**24 EXA ZETTA YOTTA, ATTA ZEPTO YOCTO And how do people avoid using MILLI for KILO, MEGA for MICRO, etc... The compiler won't care but usage could look odd.