bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] add new ronna and quetta SI prefixes


From: Pádraig Brady
Subject: [PATCH] add new ronna and quetta SI prefixes
Date: Tue, 29 Nov 2022 16:13:09 +0000

As voted for in Nov 2022 but the BIPM:
https://www.bipm.org/en/cgpm-2022/resolution-3

* lib/human.c: Add Ronna (10^27), and Quetta (10^30) to the prefix list.
* lib/xstrtol.c (__xstrtol): Likewise.
---
 ChangeLog     |  9 +++++++++
 lib/human.c   |  4 +++-
 lib/xstrtol.c | 10 +++++++++-
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e1b00bf5c9..12887e3917 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2022-11-29  Pádraig Brady  <P@draigBrady.com>
+
+       add new ronna and quetta SI prefixes
+       As voted for in Nov 2022 but the BIPM:
+       https://www.bipm.org/en/cgpm-2022/resolution-3
+
+       * lib/human.c: Add Ronna (10^27), and Quetta (10^30) to the prefix list.
+       * lib/xstrtol.c (__xstrtol): Likewise.
+
 2022-11-29  Bruno Haible  <bruno@clisp.org>
 
        Update users.txt.
diff --git a/lib/human.c b/lib/human.c
index df537271bd..0ce23a6b1d 100644
--- a/lib/human.c
+++ b/lib/human.c
@@ -43,7 +43,9 @@ static const char power_letter[] =
   'P',  /* peta or pebi */
   'E',  /* exa or exbi */
   'Z',  /* zetta or 2**70 */
-  'Y'   /* yotta or 2**80 */
+  'Y',  /* yotta or 2**80 */
+  'R',  /* ronna or 2**90 */
+  'Q'   /* quetta or 2**100 */
 };
 
 
diff --git a/lib/xstrtol.c b/lib/xstrtol.c
index e0a692ff2c..0c9910bbff 100644
--- a/lib/xstrtol.c
+++ b/lib/xstrtol.c
@@ -140,7 +140,7 @@ __xstrtol (const char *s, char **ptr, int strtol_base,
       switch (**p)
         {
         case 'E': case 'G': case 'g': case 'k': case 'K': case 'M': case 'm':
-        case 'P': case 'T': case 't': case 'Y': case 'Z':
+        case 'P': case 'Q': case 'R': case 'T': case 't': case 'Y': case 'Z':
 
           /* The "valid suffix" '0' is a special flag meaning that
              an optional second suffix is allowed, which can change
@@ -205,6 +205,14 @@ __xstrtol (const char *s, char **ptr, int strtol_base,
           overflow = bkm_scale_by_power (&tmp, base, 5);
           break;
 
+        case 'Q': /* quetta or 2**100 */
+          overflow = bkm_scale_by_power (&tmp, base, 10);
+          break;
+
+        case 'R': /* ronna or 2**90 */
+          overflow = bkm_scale_by_power (&tmp, base, 9);
+          break;
+
         case 'T': /* tera or tebi */
         case 't': /* 't' is undocumented; for compatibility only */
           overflow = bkm_scale_by_power (&tmp, base, 4);
-- 
2.26.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]