Skip to content

Commit c4aaafd

Browse files
authored
Merge pull request #8540 from diffblue/ieee_float_precondition
`ieee_floatt`: add preconditions
2 parents d5cf498 + 08a010d commit c4aaafd

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/util/ieee_float.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,8 @@ ieee_floatt &ieee_floatt::operator-=(const ieee_floatt &other)
915915

916916
bool ieee_floatt::operator<(const ieee_floatt &other) const
917917
{
918+
PRECONDITION(other.spec == spec);
919+
918920
if(NaN_flag || other.NaN_flag)
919921
return false;
920922

@@ -961,6 +963,8 @@ bool ieee_floatt::operator<(const ieee_floatt &other) const
961963

962964
bool ieee_floatt::operator<=(const ieee_floatt &other) const
963965
{
966+
PRECONDITION(other.spec == spec);
967+
964968
if(NaN_flag || other.NaN_flag)
965969
return false;
966970

@@ -994,6 +998,8 @@ bool ieee_floatt::operator>=(const ieee_floatt &other) const
994998

995999
bool ieee_floatt::operator==(const ieee_floatt &other) const
9961000
{
1001+
PRECONDITION(other.spec == spec);
1002+
9971003
// packed equality!
9981004
if(NaN_flag && other.NaN_flag)
9991005
return true;
@@ -1016,6 +1022,8 @@ bool ieee_floatt::operator==(const ieee_floatt &other) const
10161022

10171023
bool ieee_floatt::ieee_equal(const ieee_floatt &other) const
10181024
{
1025+
PRECONDITION(other.spec == spec);
1026+
10191027
if(NaN_flag || other.NaN_flag)
10201028
return false;
10211029
if(is_zero() && other.is_zero())
@@ -1038,6 +1046,8 @@ bool ieee_floatt::operator!=(const ieee_floatt &other) const
10381046

10391047
bool ieee_floatt::ieee_not_equal(const ieee_floatt &other) const
10401048
{
1049+
PRECONDITION(other.spec == spec);
1050+
10411051
if(NaN_flag || other.NaN_flag)
10421052
return true; // !!!
10431053
if(is_zero() && other.is_zero())

0 commit comments

Comments
 (0)