Skip to content

Commit

Permalink
Cleanup ieee_floatt interface
Browse files Browse the repository at this point in the history
Use constructor chaining to avoid code duplication and remove the unused
operator==(int).
  • Loading branch information
tautschnig committed Sep 10, 2024
1 parent 6be3d4d commit f09a19b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 27 deletions.
7 changes: 0 additions & 7 deletions src/util/ieee_float.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1024,13 +1024,6 @@ bool ieee_floatt::ieee_equal(const ieee_floatt &other) const
return *this==other;
}

bool ieee_floatt::operator==(int i) const
{
ieee_floatt other(spec);
other.from_integer(i);
return *this==other;
}

bool ieee_floatt::operator!=(const ieee_floatt &other) const
{
return !(*this==other);
Expand Down
28 changes: 8 additions & 20 deletions src/util/ieee_float.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,6 @@ class ieee_floatt

ieee_float_spect spec;

explicit ieee_floatt(const ieee_float_spect &_spec):
rounding_mode(ROUND_TO_EVEN),
spec(_spec), sign_flag(false), exponent(0), fraction(0),
NaN_flag(false), infinity_flag(false)
{
}

explicit ieee_floatt(ieee_float_spect __spec, rounding_modet __rounding_mode)
: rounding_mode(__rounding_mode),
spec(std::move(__spec)),
Expand All @@ -151,21 +144,17 @@ class ieee_floatt
{
}

explicit ieee_floatt(const floatbv_typet &type):
rounding_mode(ROUND_TO_EVEN),
spec(ieee_float_spect(type)),
sign_flag(false),
exponent(0),
fraction(0),
NaN_flag(false),
infinity_flag(false)
explicit ieee_floatt(const ieee_float_spect &_spec)
: ieee_floatt(_spec, ROUND_TO_EVEN)
{
}

explicit ieee_floatt(const floatbv_typet &type)
: ieee_floatt(ieee_float_spect(type))
{
}

ieee_floatt():
rounding_mode(ROUND_TO_EVEN),
sign_flag(false), exponent(0), fraction(0),
NaN_flag(false), infinity_flag(false)
ieee_floatt() : ieee_floatt(ieee_float_spect{}, ROUND_TO_EVEN)
{
}

Expand Down Expand Up @@ -305,7 +294,6 @@ class ieee_floatt
// e.g., NAN==NAN
bool operator==(const ieee_floatt &other) const;
bool operator!=(const ieee_floatt &other) const;
bool operator==(int i) const;

// these do IEEE equality, i.e., NAN!=NAN
bool ieee_equal(const ieee_floatt &other) const;
Expand Down

0 comments on commit f09a19b

Please sign in to comment.