/// <summary> /// creates a number using a digit and an order of magnitude /// </summary> /// <param name="orderOfMag"></param> /// <param name="digit"></param> /// <returns></returns> public static IDigitNode GetDigitAtMagnitude(this INumeric thisNumber, Numeric orderOfMag) { if (thisNumber == null) throw new ArgumentNullException("thisNumber"); if (orderOfMag == null) throw new ArgumentNullException("orderOfMag"); if (orderOfMag.IsEqualTo(orderOfMag.GetCompatibleZero())) return thisNumber.ZerothDigit; IDigitNode rv = null; if (orderOfMag.IsPositive) { rv = thisNumber.ZerothDigit; orderOfMag.PerformThisManyTimes(x => { if (rv != null) rv = rv.NextDigit(); }); } else { rv = thisNumber.ZerothDigit; orderOfMag.GetNegativeOf().PerformThisManyTimes(x => { if (rv != null) rv = rv.PreviousDigit(); }); } return rv; }