From: Jacob Lifshay Date: Wed, 17 May 2023 04:50:47 +0000 (-0700) Subject: add fp value to BFPState.__repr__ X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e8f4a3e6f8294e200fe6f1f8682d0c57f390292d;p=openpower-isa.git add fp value to BFPState.__repr__ --- diff --git a/src/openpower/decoder/fp_working_format.py b/src/openpower/decoder/fp_working_format.py index b1fdf56c..0dfc9bba 100644 --- a/src/openpower/decoder/fp_working_format.py +++ b/src/openpower/decoder/fp_working_format.py @@ -436,9 +436,26 @@ class BFPState: f"significand: {self.significand}", *self.class_._bfp_state_fields()) + def __str__(self): + if self.class_.SNaN: + return "SNaN" + if self.class_.QNaN: + return "QNaN" + if self.class_.Infinity: + return "-Inf" if self.sign else "Inf" + retval = self.significand + if self.sign: + retval = -retval + retval <<= self.exponent + sign = "" + if retval < 0: + sign = "-" + retval = -retval + return sign + retval.__str__(max_int_digits=16) + def __repr__(self): fields = self._bfp_state_fields() - return f"" + return f"" # TODO: add tests