示例#1
0
        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));
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }