From e8f4a3e6f8294e200fe6f1f8682d0c57f390292d Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Tue, 16 May 2023 21:50:47 -0700 Subject: [PATCH] add fp value to BFPState.__repr__ --- src/openpower/decoder/fp_working_format.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) 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 -- 2.30.2