Skip to content

ieee_floatt: add preconditions #8540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/util/ieee_float.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,8 @@ ieee_floatt &ieee_floatt::operator-=(const ieee_floatt &other)

bool ieee_floatt::operator<(const ieee_floatt &other) const
{
PRECONDITION(other.spec == spec);

if(NaN_flag || other.NaN_flag)
return false;

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

bool ieee_floatt::operator<=(const ieee_floatt &other) const
{
PRECONDITION(other.spec == spec);

if(NaN_flag || other.NaN_flag)
return false;

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

bool ieee_floatt::operator==(const ieee_floatt &other) const
{
PRECONDITION(other.spec == spec);

// packed equality!
if(NaN_flag && other.NaN_flag)
return true;
Expand All @@ -1016,6 +1022,8 @@ bool ieee_floatt::operator==(const ieee_floatt &other) const

bool ieee_floatt::ieee_equal(const ieee_floatt &other) const
{
PRECONDITION(other.spec == spec);

if(NaN_flag || other.NaN_flag)
return false;
if(is_zero() && other.is_zero())
Expand All @@ -1038,6 +1046,8 @@ bool ieee_floatt::operator!=(const ieee_floatt &other) const

bool ieee_floatt::ieee_not_equal(const ieee_floatt &other) const
{
PRECONDITION(other.spec == spec);

if(NaN_flag || other.NaN_flag)
return true; // !!!
if(is_zero() && other.is_zero())
Expand Down
Loading