From: Jacob Lifshay Date: Sun, 14 Jul 2019 09:42:43 +0000 (-0700) Subject: reduce code duplication X-Git-Tag: ls180-24jan2020~843 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=29faeee8c31f71b7c4a05ee5aab9bafd2d50083a;p=ieee754fpu.git reduce code duplication --- diff --git a/src/ieee754/fpcommon/fpbase.py b/src/ieee754/fpcommon/fpbase.py index ecb2a632..b8deab02 100644 --- a/src/ieee754/fpcommon/fpbase.py +++ b/src/ieee754/fpcommon/fpbase.py @@ -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}"