/// <summary>Decimal value</summary> public void InitDouble(double val, Restrictions restrictions) { this.deciValue = val; if (val == Math.Floor(val)) { //this is done to avoid the accumulation of miniscule errors: deciValue = Math.Floor(val); primaryNumType = NumberType.integer; if (restrictions != Restrictions.dontFactorMe && restrictions != Restrictions.dontFactorDontSetFraction) { factors = new Factors((int)deciValue); } natural = new MathNet.Numerics.Natural(); } else if (restrictions != Restrictions.dontSetToFraction && restrictions != Restrictions.dontFactorDontSetFraction) { asAFraction = decimalToFraction(deciValue); } this.primaryNumType = NumberType.deci; }
/// <summary>Decimal value</summary> public void InitDouble(double val, Restrictions restrictions) { this.deciValue = val; if (val == Math.Floor(val)) { //this is done to avoid the accumulation of miniscule errors: deciValue = Math.Floor(val); primaryNumType = NumberType.integer; if (restrictions != Restrictions.dontFactorMe && restrictions != Restrictions.dontFactorDontSetFraction) { factors = new Factors((int)deciValue); } natural = new MathNet.Numerics.Natural(); }else if (restrictions != Restrictions.dontSetToFraction && restrictions != Restrictions.dontFactorDontSetFraction) { asAFraction = decimalToFraction(deciValue); } this.primaryNumType = NumberType.deci; }