From 0ad3ea4951f77835d02180021589f3a849d885f2 Mon Sep 17 00:00:00 2001
From: =?utf8?q?P=C3=A1draig=20Brady?=
Date: Tue, 29 Nov 2022 15:05:07 +0000
Subject: [PATCH] add new ronna and quetta SI prefixes
As voted for in Nov 2022 by 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..90664d16a5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2022-11-29 Pádraig Brady
+
+ add new ronna and quetta SI prefixes
+ As voted for in Nov 2022 by 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
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.39.5