reduce code duplication
authorJacob Lifshay <programmerjake@gmail.com>
Sun, 14 Jul 2019 09:42:43 +0000 (02:42 -0700)
committerJacob Lifshay <programmerjake@gmail.com>
Sun, 14 Jul 2019 09:42:43 +0000 (02:42 -0700)
src/ieee754/fpcommon/fpbase.py

index ecb2a632b661f45ee32e30cf76b8334821229c70..b8deab021f2f8080270b71a656bb7ebf7e20f030 100644 (file)
@@ -71,10 +71,11 @@ class FPFormat:
 
     def __repr__(self):
         """ Get repr. """
-        if (self.width in (16, 32, 64, 128)
-                or (self.width > 128 and self.width % 32 == 0)):
+        try:
             if self == self.standard(self.width):
                 return f"FPFormat.standard({self.width})"
+        except ValueError:
+            pass
         retval = f"FPFormat({self.exponent_width}, {self.mantissa_width}"
         if self.has_int_bit is not False:
             retval += f", {self.has_int_bit}"