BitVector FloatingPoint::pack(void) const { return d_fpl->pack(); }
-std::string FloatingPoint::toString(bool printAsIndexed) const
+void FloatingPoint::getIEEEBitvectors(BitVector& sign,
+ BitVector& exp,
+ BitVector& sig) const
{
- std::string str;
- // retrive BV value
+ // retrieve BV value
BitVector bv(pack());
uint32_t largestSignificandBit =
getSize().significandWidth() - 2; // -1 for -inclusive, -1 for hidden
uint32_t largestExponentBit =
(getSize().exponentWidth() - 1) + (largestSignificandBit + 1);
+ sign = bv.extract(largestExponentBit + 1, largestExponentBit + 1);
+ exp = bv.extract(largestExponentBit, largestSignificandBit + 1);
+ sig = bv.extract(largestSignificandBit, 0);
+}
+
+std::string FloatingPoint::toString(bool printAsIndexed) const
+{
+ std::string str;
+ // retrive BV value
BitVector v[3];
- v[0] = bv.extract(largestExponentBit + 1, largestExponentBit + 1);
- v[1] = bv.extract(largestExponentBit, largestSignificandBit + 1);
- v[2] = bv.extract(largestSignificandBit, 0);
+ getIEEEBitvectors(v[0], v[1], v[2]);
str.append("(fp ");
for (uint32_t i = 0; i < 3; ++i)
{
*/
std::string toString(bool printAsIndexed = false) const;
+ /**
+ * Get the IEEE bit-vector representation of this floating-point value.
+ * Stores the sign bit in `sign`, the exponent in `exp` and the significand
+ * in `sig`.
+ */
+ void getIEEEBitvectors(BitVector& sign, BitVector& exp, BitVector& sig) const;
+
/** Return the packed (IEEE-754) representation of this floating-point. */
BitVector pack(void) const;