Refactor static normalize

- Use a single worker function that does all the work and explicit
  template instantiation. If this gives me any more trouble, I'm just
  going to move normalize into the header, but I was hoping to avoid
  that.
This commit is contained in:
Ed Hennis
2025-12-10 16:06:54 -05:00
parent 5400381cac
commit 254d325a3e
2 changed files with 45 additions and 17 deletions

View File

@@ -327,6 +327,15 @@ private:
internalrep const& minMantissa,
internalrep const& maxMantissa);
template <class T>
friend void
doNormalize(
bool& negative,
T& mantissa_,
int& exponent_,
MantissaRange::rep const& minMantissa,
MantissaRange::rep const& maxMantissa);
bool
isnormal() const noexcept;
@@ -537,17 +546,6 @@ Number::isnormal() const noexcept
exponent_ <= maxExponent);
}
// Because the template function definition is in the .cpp file, declare
// some of the overrides used outside of this class here.
template <>
void
Number::normalize<unsigned long>(
bool& negative,
unsigned long& mantissa,
int& exponent,
internalrep const& minMantissa,
internalrep const& maxMantissa);
template <class T>
std::pair<T, int>
Number::normalizeToRange(T minMantissa, T maxMantissa) const