Esempio n. 1
0
 /**
  * assumes both this and other are normalised
  */
 public int CompareNormalised(NormalisedDecimal other)
 {
     int cmp = _relativeDecimalExponent - other._relativeDecimalExponent;
     if (cmp != 0)
     {
         return cmp;
     }
     if (_wholePart > other._wholePart)
     {
         return 1;
     }
     if (_wholePart < other._wholePart)
     {
         return -1;
     }
     return _fractionalPart - other._fractionalPart;
 }
 private static void ConvertToText(StringBuilder sb, NormalisedDecimal pnd)
 {
     NormalisedDecimal rnd = pnd.RoundUnits();
     int decExponent = rnd.GetDecimalExponent();
     String decimalDigits;
     if (Math.Abs(decExponent) > 98)
     {
         decimalDigits = rnd.GetSignificantDecimalDigitsLastDigitRounded();
         if (decimalDigits.Length == 16)
         {
             // rounding caused carry
             decExponent++;
         }
     }
     else
     {
         decimalDigits = rnd.GetSignificantDecimalDigits();
     }
     int countSigDigits = CountSignifantDigits(decimalDigits);
     if (decExponent < 0)
     {
         FormatLessThanOne(sb, decimalDigits, decExponent, countSigDigits);
     }
     else
     {
         FormatGreaterThanOne(sb, decimalDigits, decExponent, countSigDigits);
     }
 }