Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/06/14 14:40:45 (11 years ago)
Author:
ascheibe
Message:

#1886 adapted convex hull modifier to use fractions for big volumes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/FractionClass.cs

    r10286 r10287  
    249249    }
    250250
     251    public double ToDouble(int digits) {
     252      if (this.m_Denominator == 1)
     253        return (double)this.m_Numerator;
     254      else if (this.m_Denominator == 0) {
     255        switch (NormalizeIndeterminate(this.m_Numerator)) {
     256          case Indeterminates.NegativeInfinity:
     257            return double.NegativeInfinity;
     258
     259          case Indeterminates.PositiveInfinity:
     260            return double.PositiveInfinity;
     261
     262          case Indeterminates.NaN:
     263          default:    // this can't happen
     264            return double.NaN;
     265        }
     266      } else {
     267        ReduceFraction(ref this);
     268        int factor = (int)Math.Pow(10, digits);
     269        return ((double)((this.m_Numerator * factor) / this.m_Denominator)) / factor;
     270      }
     271    }
     272
    251273    /// <summary>
    252274    /// Get the value of the Fraction as a string, with proper representation for NaNs and infinites
Note: See TracChangeset for help on using the changeset viewer.