From 29faeee8c31f71b7c4a05ee5aab9bafd2d50083a Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Sun, 14 Jul 2019 02:42:43 -0700 Subject: [PATCH] reduce code duplication --- src/ieee754/fpcommon/fpbase.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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}" -- 2.30.2