summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Mitz <mitza@ociweb.com>2015-04-29 13:05:46 -0500
committerAdam Mitz <mitza@ociweb.com>2015-04-29 13:05:46 -0500
commitae39042c3ffdd67269848432410289e4d3c7550f (patch)
tree481b08551076debaa3acae561f3143c3e9d1247a
parent85e67c0683c8f79453ba05c77a34cd434d9bfcc7 (diff)
parent2c44da619b25eea55853878edc97a6569ab01faf (diff)
downloadATCD-ae39042c3ffdd67269848432410289e4d3c7550f.tar.gz
Merge pull request #67 from mitza-oci/master
ACE_CDR::Fixed corrected a bug and short-circuit division by 1.
-rw-r--r--ACE/ace/CDR_Base.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/ACE/ace/CDR_Base.cpp b/ACE/ace/CDR_Base.cpp
index 484c809ca23..b2ee413e985 100644
--- a/ACE/ace/CDR_Base.cpp
+++ b/ACE/ace/CDR_Base.cpp
@@ -1348,7 +1348,10 @@ ACE_CDR::Fixed &ACE_CDR::Fixed::operator/= (const Fixed &rhs)
if (rhs.scale_ && rhs.scale_ <= this->scale_)
this->scale_ -= rhs.scale_;
else if (rhs.scale_)
- this->scale_ -= this->lshift (rhs.scale_ - this->scale_);
+ {
+ const Octet shifted = this->lshift (rhs.scale_ - this->scale_);
+ this->scale_ -= shifted;
+ }
Fixed rhs_no_scale = rhs;
rhs_no_scale.scale_ = 0;
@@ -1362,10 +1365,14 @@ ACE_CDR::Fixed &ACE_CDR::Fixed::operator/= (const Fixed &rhs)
else if (this->sign () && rhs.sign ())
this->value_[15] = (this->value_[15] & 0xf0) | POSITIVE;
- static const Fixed two = from_integer (LongLong (2)),
+ static const Fixed one = from_integer (LongLong (1)),
+ two = from_integer (LongLong (2)),
three = from_integer (LongLong (3)),
five = from_integer (LongLong (5));
+ if (rhs_no_scale == one)
+ return *this;
+
// Most sig digit of rhs must be >= 5
switch (rhs_no_scale.digit (rhs_no_scale.digits_ - 1))
{