Remove unused code.

上级 d5a5fac9
......@@ -94,44 +94,6 @@ namespace GrisuDotNet
f_ = result_f;
}
// returns a * b;
public static DiyFp Times(ref DiyFp a, ref DiyFp b)
{
DiyFp result = a;
result.Multiply(ref b);
return result;
}
public void Normalize()
{
Debug.Assert(f_ != 0);
ulong f = f_;
int e = e_;
// This method is mainly called for normalizing boundaries. In general
// boundaries need to be shifted by 10 bits. We thus optimize for this case.
const ulong k10MSBits = 0xFFC0000000000000;
while ((f & k10MSBits) == 0)
{
f <<= 10;
e -= 10;
}
while ((f & kUint64MSB) == 0)
{
f <<= 1;
e--;
}
f_ = f;
e_ = e;
}
public static DiyFp Normalize(ref DiyFp a)
{
DiyFp result = a;
result.Normalize();
return result;
}
public ulong F
{
get { return f_; }
......
......@@ -35,7 +35,6 @@ namespace GrisuDotNet
[CSToJavaExclude]
internal struct GrisuDouble
{
const ulong kSignMask = 0x8000000000000000;
const ulong kExponentMask = 0x7FF0000000000000;
const ulong kSignificandMask = 0x000FFFFFFFFFFFFF;
const ulong kHiddenBit = 0x0010000000000000;
......@@ -44,8 +43,6 @@ namespace GrisuDotNet
const int kExponentBias = 0x3FF + kPhysicalSignificandSize;
const int kDenormalExponent = -kExponentBias + 1;
const int kMaxExponent = 0x7FF - kExponentBias;
const ulong kInfinity = 0x7FF0000000000000;
public GrisuDouble(double d)
{
......@@ -53,27 +50,6 @@ namespace GrisuDotNet
d64_ = (ulong)BitConverter.DoubleToInt64Bits(d);
}
public GrisuDouble(ulong d64)
{
d64_ = d64;
value_ = BitConverter.Int64BitsToDouble((long)d64);
}
public GrisuDouble(DiyFp diy_fp)
{
d64_ = DiyFpToUInt64(diy_fp);
value_ = BitConverter.Int64BitsToDouble((long)d64_);
}
// The value encoded by this Double must be greater or equal to +0.0.
// It must not be special (infinity, or NaN).
public DiyFp AsDiyFp()
{
Debug.Assert(Sign > 0);
Debug.Assert(!IsSpecial);
return new DiyFp(Significand, Exponent);
}
// The value encoded by this Double must be strictly greater than 0.
public DiyFp AsNormalizedDiyFp()
{
......@@ -105,41 +81,6 @@ namespace GrisuDotNet
return new DiyFp(f, e);
}
// Returns the double's bit as UInt64.
public ulong AsUInt64()
{
return d64_;
}
public int Exponent
{
get
{
if (IsDenormal) return kDenormalExponent;
int biased_e =
(int)((d64_ & kExponentMask) >> kPhysicalSignificandSize);
return biased_e - kExponentBias;
}
}
public ulong Significand
{
get
{
ulong significand = d64_ & kSignificandMask;
if (IsDenormal)
{
return significand;
}
else
{
return significand + kHiddenBit;
}
}
}
// Returns true if the double is a denormal.
public bool IsDenormal
{
......@@ -177,22 +118,6 @@ namespace GrisuDotNet
}
}
public int Sign
{
get
{
return (d64_ & kSignMask) == 0 ? 1 : -1;
}
}
// Precondition: the value encoded by this Double must be greater or equal
// than +0.0.
public DiyFp UpperBoundary()
{
Debug.Assert(Sign > 0);
return new DiyFp(Significand * 2 + 1, Exponent - 1);
}
// Computes the two boundaries of this.
// The bigger boundary (m_plus) is normalized. The lower boundary has the same
// exponent as m_plus.
......@@ -262,73 +187,6 @@ namespace GrisuDotNet
get { return value_; }
}
// Returns the significand size for a given order of magnitude.
// If v = f*2^e with 2^p-1 <= f <= 2^p then p+e is v's order of magnitude.
// This function returns the number of significant binary digits v will have
// once it's encoded into a double. In almost all cases this is equal to
// kSignificandSize. The only exceptions are denormals. They start with
// leading zeroes and their effective significand-size is hence smaller.
public static int SignificandSizeForOrderOfMagnitude(int order)
{
if (order >= (kDenormalExponent + kSignificandSize))
{
return kSignificandSize;
}
if (order <= kDenormalExponent) return 0;
return order - kDenormalExponent;
}
public static double Infinity
{
get
{
return double.PositiveInfinity;
}
}
public static double NaN
{
get
{
return double.NaN;
}
}
private static ulong DiyFpToUInt64(DiyFp diy_fp)
{
ulong significand = diy_fp.F;
int exponent = diy_fp.E;
while (significand > kHiddenBit + kSignificandMask)
{
significand >>= 1;
exponent++;
}
if (exponent >= kMaxExponent)
{
return kInfinity;
}
if (exponent < kDenormalExponent)
{
return 0;
}
while (exponent > kDenormalExponent && (significand & kHiddenBit) == 0)
{
significand <<= 1;
exponent--;
}
ulong biased_exponent;
if (exponent == kDenormalExponent && (significand & kHiddenBit) == 0)
{
biased_exponent = 0;
}
else
{
biased_exponent = (ulong)(exponent + kExponentBias);
}
return (significand & kSignificandMask) |
(biased_exponent << kPhysicalSignificandSize);
}
private ulong d64_;
private double value_;
}
......
......@@ -62,26 +62,6 @@ namespace GrisuDotNet
power = new DiyFp(cached_power.significand, cached_power.binary_exponent);
}
// Returns a cached power of ten x ~= 10^k such that
// k <= decimal_exponent < k + kCachedPowersDecimalDistance.
// The given decimal_exponent must satisfy
// kMinDecimalExponent <= requested_exponent, and
// requested_exponent < kMaxDecimalExponent + kDecimalExponentDistance.
public static void GetCachedPowerForDecimalExponent(int requested_exponent,
out DiyFp power,
out int found_exponent)
{
Debug.Assert(kMinDecimalExponent <= requested_exponent);
Debug.Assert(requested_exponent < kMaxDecimalExponent + kDecimalExponentDistance);
int index =
(requested_exponent + kCachedPowersOffset) / kDecimalExponentDistance;
CachedPower cached_power = kCachedPowers[index];
power = new DiyFp(cached_power.significand, cached_power.binary_exponent);
found_exponent = cached_power.decimal_exponent;
Debug.Assert(found_exponent <= requested_exponent);
Debug.Assert(requested_exponent < found_exponent + kDecimalExponentDistance);
}
struct CachedPower
{
public ulong significand;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册