-// Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
+// Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
bool sticky{false};
while (!product.upper.IsZero()) {
sticky |= product.lower.BTEST(0);
- product.lower = product.lower.DSHIFTR(product.upper, 1);
+ product.lower = product.lower.SHIFTRWithFill(product.upper, 1);
product.upper = product.upper.SHIFTR(1);
++exponent_;
}
return unchanged.IOR(middle).IOR(least);
}
- // Double shifts, aka shifts with specific fill
- constexpr Integer DSHIFTL(const Integer &fill, int count) const {
+ // Double shifts, aka shifts with specific fill.
+ constexpr Integer SHIFTLWithFill(const Integer &fill, int count) const {
if (count <= 0) {
return *this;
} else if (count >= 2 * bits) {
}
}
- constexpr Integer DSHIFTR(const Integer &fill, int count) const {
+ constexpr Integer SHIFTRWithFill(const Integer &fill, int count) const {
if (count <= 0) {
return *this;
} else if (count >= 2 * bits) {
}
}
+ constexpr Integer DSHIFTL(const Integer &fill, int count) const {
+ // DSHIFTL(I,J) shifts I:J left; the second argument is the right fill.
+ return SHIFTLWithFill(fill, count);
+ }
+
+ constexpr Integer DSHIFTR(const Integer &value, int count) const {
+ // DSHIFTR(I,J) shifts I:J right; the *first* argument is the left fill.
+ return value.SHIFTRWithFill(*this, count);
+ }
+
// Vacated upper bits are filled with zeroes.
constexpr Integer SHIFTR(int count) const {
if (count <= 0) {
-// Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
+// Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
} else {
sticky = !product.lower.IAND(product.lower.MASKR(rshift)).IsZero();
}
- product.lower = product.lower.DSHIFTR(product.upper, rshift);
+ product.lower = product.lower.SHIFTRWithFill(product.upper, rshift);
product.upper = product.upper.SHIFTR(rshift);
if (sticky) {
product.lower = product.lower.IBSET(0);
lshift = exponent - 1;
}
exponent -= lshift;
- product.upper = product.upper.DSHIFTL(product.lower, lshift);
+ product.upper = product.upper.SHIFTLWithFill(product.lower, lshift);
product.lower = product.lower.SHIFTL(lshift);
RoundingBits roundingBits{product.lower, product.lower.bits};
NormalizeAndRound(result, isNegative, exponent, product.upper, rounding,