/// <summary> /// if a number is A + B where A is integer and B is in [0; 1], it performs operations /// for A and B separately and then concatenates /// </summary> /// <param name="num"></param> /// <param name="N"></param> /// <returns></returns> internal static string ToBaseN(EDecimal num, int N) { if (N > ALPHABET_TOCHAR.Length) { throw new MathSException("N should be <= than " + ALPHABET_TOCHAR.Length); } string sign = EDecimalWrapper.IsLess(num, 0) ? "-" : ""; num = num.Abs(); var intPart = num.RoundToIntegerExact(FloorContext).ToEInteger(); EDecimal floatPart = RealNumber.CtxSubtract(num, intPart); string rightPart = !EDecimalWrapper.IsEqual(floatPart, 0) ? "." + FloatToBaseN(floatPart, N) : ""; string leftPart = sign + IntToBaseN(intPart, N); return(leftPart + rightPart); }