Skip to content

Rename parameters of div_and_round [blocks: #2310] #3331

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
Nov 10, 2018
Merged
Show file tree
Hide file tree
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
24 changes: 12 additions & 12 deletions src/util/ieee_float.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,31 +646,31 @@ void ieee_floatt::align()
}

void ieee_floatt::divide_and_round(
mp_integer &fraction,
const mp_integer &factor)
mp_integer &dividend,
const mp_integer &divisor)
{
mp_integer remainder=fraction%factor;
fraction/=factor;
const mp_integer remainder = dividend % divisor;
dividend /= divisor;

if(remainder!=0)
{
switch(rounding_mode)
{
case ROUND_TO_EVEN:
{
mp_integer factor_middle=factor/2;
if(remainder<factor_middle)
mp_integer divisor_middle = divisor / 2;
if(remainder < divisor_middle)
{
// crop
}
else if(remainder>factor_middle)
else if(remainder > divisor_middle)
{
++fraction;
++dividend;
}
else // exactly in the middle -- go to even
{
if((fraction%2)!=0)
++fraction;
if((dividend % 2) != 0)
++dividend;
}
}
break;
Expand All @@ -681,12 +681,12 @@ void ieee_floatt::divide_and_round(

case ROUND_TO_MINUS_INF:
if(sign_flag)
++fraction;
++dividend;
break;

case ROUND_TO_PLUS_INF:
if(!sign_flag)
++fraction;
++dividend;
break;

default:
Expand Down
2 changes: 1 addition & 1 deletion src/util/ieee_float.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ class ieee_floatt
bool ieee_not_equal(const ieee_floatt &other) const;

protected:
void divide_and_round(mp_integer &fraction, const mp_integer &factor);
void divide_and_round(mp_integer &dividend, const mp_integer &divisor);
void align();
void next_representable(bool greater);

Expand Down