public virtual string ConvertFromRadix10(int NumberToConvert, int RadixValue, int RadixSpaceCounter, char RadixSeperationCharacter) { int NumberCalculated = 0; int Carry = 0; string OutputString = ""; int StringCounter = 0; do { StringCounter++; NumberCalculated = NumberToConvert / RadixValue; Carry = NumberToConvert % RadixValue; OutputString += NumberSystemHelper.MyCharConverter(Carry); if (0 != RadixSpaceCounter) { if (0 == StringCounter % RadixSpaceCounter) { OutputString += RadixSeperationCharacter; } } NumberToConvert = NumberCalculated; } while (NumberCalculated > 0); return(StringHelper.ReverseString(OutputString)); }
public virtual int ConvertToRadix10(string RadixStringToConvert, int RadixValue, char CharacterToRemove) { int Radix10Value = 0; RadixStringToConvert = StringHelper.ReverseString(RadixStringToConvert); RadixStringToConvert = StringHelper.TrimAndRemoveSpecifiedCharacterFromString(RadixStringToConvert, CharacterToRemove); for (int Counter = 0; Counter < RadixStringToConvert.Length; Counter++) { Radix10Value += (int)Math.Pow(RadixValue, Counter) * NumberSystemHelper.MyNumberConverter(RadixStringToConvert[Counter]); } return(Radix10Value); }
public virtual int ConvertToRadix10(string RadixStringToConvert, RadixNumber_ENUM Radix) { int Radix10Value = 0; RadixStringToConvert = StringHelper.ReverseString(RadixStringToConvert); for (int Counter = 0; Counter < RadixStringToConvert.Length; Counter++) { //if (RadixNumber_ENUM.HEXADECIMAL_NUMBER == Radix) //{ // Radix10Value += (int)Math.Pow((int)Radix, Counter) * int.Parse(RadixStringToConvert[Counter].ToString(), // System.Globalization.NumberStyles.HexNumber); //} //else //{ // Radix10Value += (int)Math.Pow((int)Radix, Counter) * (int)Char.GetNumericValue(RadixStringToConvert[Counter]); //} Radix10Value += (int)Math.Pow((int)Radix, Counter) * NumberSystemHelper.MyNumberConverter(RadixStringToConvert[Counter]); } return(Radix10Value); }