Browse Source

Add Ronna (10^27), and Quetta (10^30) SI prefixes.

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

Sync with gnulib 0ad3ea4951f77835d02180021589f3a849d885f2.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Andrew Borodin 2 years ago
parent
commit
3ad5f5502f
2 changed files with 14 additions and 2 deletions
  1. 10 0
      lib/strutil/xstrtol.c
  2. 4 2
      lib/util.c

+ 10 - 0
lib/strutil/xstrtol.c

@@ -147,6 +147,8 @@ xstrtoumax (const char *s, char **ptr, int base, uintmax_t * val, const char *va
         case 'M':
         case 'm':
         case 'P':
+        case 'Q':
+        case 'R':
         case 'T':
         case 't':
         case 'Y':
@@ -221,6 +223,14 @@ xstrtoumax (const char *s, char **ptr, int base, uintmax_t * val, const char *va
             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);

+ 4 - 2
lib/util.c

@@ -451,8 +451,10 @@ size_trunc_len (char *buffer, unsigned int len, uintmax_t size, int units, gbool
 #endif
     };
     /* *INDENT-ON* */
-    static const char *const suffix[] = { "", "K", "M", "G", "T", "P", "E", "Z", "Y", NULL };
-    static const char *const suffix_lc[] = { "", "k", "m", "g", "t", "p", "e", "z", "y", NULL };
+    static const char *const suffix[] =
+        { "", "K", "M", "G", "T", "P", "E", "Z", "Y", "R", "Q", NULL };
+    static const char *const suffix_lc[] =
+        { "", "k", "m", "g", "t", "p", "e", "z", "y", "r", "q", NULL };
 
     const char *const *sfx = use_si ? suffix_lc : suffix;
     int j = 0;