]> git.lizzy.rs Git - rust.git/blobdiff - src/etc/dec2flt_table.py
Auto merge of #69156 - ecstatic-morse:unified-dataflow-impls2, r=eddyb
[rust.git] / src / etc / dec2flt_table.py
old mode 100644 (file)
new mode 100755 (executable)
index 2ffaf13..4979882
@@ -14,7 +14,6 @@ is used because (u64, i16) has a ton of padding which would make the table
 even larger, and it's already uncomfortably large (6 KiB).
 """
 from __future__ import print_function
-import sys
 from math import ceil, log
 from fractions import Fraction
 from collections import namedtuple
@@ -82,6 +81,7 @@ def error(f, e, z):
     ulp_err = abs_err / Fraction(2) ** z.exp
     return float(ulp_err)
 
+
 HEADER = """
 //! Tables of approximations of powers of ten.
 //! DO NOT MODIFY: Generated by `src/etc/dec2flt_table.py`
@@ -111,14 +111,18 @@ def print_proper_powers():
     print("pub const MIN_E: i16 = {};".format(MIN_E))
     print("pub const MAX_E: i16 = {};".format(MAX_E))
     print()
+    print("#[rustfmt::skip]")
     typ = "([u64; {0}], [i16; {0}])".format(len(powers))
-    print("pub const POWERS: ", typ, " = ([", sep='')
+    print("pub const POWERS: ", typ, " = (", sep='')
+    print("    [")
     for z in powers:
-        print("    0x{:x},".format(z.sig))
-    print("], [")
+        print("        0x{:x},".format(z.sig))
+    print("    ],")
+    print("    [")
     for z in powers:
-        print("    {},".format(z.exp))
-    print("]);")
+        print("        {},".format(z.exp))
+    print("    ],")
+    print(");")
 
 
 def print_short_powers(num_bits, significand_size):
@@ -127,6 +131,7 @@ def print_short_powers(num_bits, significand_size):
     max_e = int(ceil(log(max_sig, 5)))
     e_range = range(max_e)
     typ = "[f{}; {}]".format(num_bits, len(e_range))
+    print("#[rustfmt::skip]")
     print("pub const F", num_bits, "_SHORT_POWERS: ", typ, " = [", sep='')
     for e in e_range:
         print("    1e{},".format(e))