Changeset 10287 for branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/FractionClass.cs
- Timestamp:
- 01/06/14 14:40:45 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/FractionClass.cs
r10286 r10287 249 249 } 250 250 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 251 273 /// <summary> 252 274 /// 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.