public static ulong convert(string numStr, byte orgSys) { ulong result = 0; for (int i = 0; i < numStr.Length; i++) { result = result * orgSys + (ulong)(Digits.Dec(numStr.ElementAt(i))); } return(result); }
public static string convert(ulong numDec, byte dstSys) { Stack <char> digitCharStack = new Stack <char>(); ulong quotient = numDec; byte remainder = 0; while (quotient != 0) { remainder = (byte)(quotient % dstSys); quotient = quotient / dstSys; digitCharStack.Push(Digits.Any(remainder)); } StringBuilder stringBuilder = new StringBuilder(digitCharStack.Count); while (digitCharStack.Count > 0) { stringBuilder.Append(digitCharStack.Pop()); } return(stringBuilder.ToString()); }
public static string convert(string numStr, char orgSys, char dstSys) { return(convert(numStr, (byte)(Digits.Dec(orgSys) + 1), (byte)(Digits.Dec(dstSys) + 1))); }