C # console base unsigned hexadecimal decimal conversion to decimal

Source: Internet
Author: User

Town Field Poem:
——— Dream who feel, the water month Build blog. Baiqian tribulation, only know the vicissitudes of the world.
——— today holds the Buddhist language, the technology is boundless willing to learn. Willing to do what you learn, cast a conscience blog.
——————————————————————————————————————————

1 Code

1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Linq;4 usingSystem.Text;5 usingSystem.Threading.Tasks;6 7 namespaceConsoleApplication158 {9     class ProgramTen     { One         Static voidMain (string[] args) A         { -             //This dictionary is designed to encounter letters prepared for 16 binary to 10 binary conversions -             //if it is a letter, then run the dictionary into a decimal number thedictionary<Char,int> tableof16_10 =Newdictionary<Char,int>(); -Tableof16_10.add ('a',Ten); -Tableof16_10.add ('b', One); -Tableof16_10.add ('C', A); +Tableof16_10.add ('D', -); -Tableof16_10.add ('e', -); +Tableof16_10.add ('F', the); A  at  -  -Console.WriteLine ("Your turn:"); -             stringValue =console.readline (); -  -             //separating strings, dividing by decimal point in             string[] values = value. Split (New Char[] {'.'}, stringsplitoptions.removeemptyentries); -  to             //A string that stores the fractional part +             stringDecimalspart = values[1]; -             //string that stores the integer part the             stringIntegerpart = values[0]; *  $             //The 10 binary numbers that are part of the decimal number must be of type double.Panax Notoginseng             DoubleSumofdecimalspart =0.0; -  the             Chartemp; +              for(inti =0; i < decimalspart.length; i++) A             { the                 //Decimalspart[i] is a char type, so add a ToString +                 //in the initial stage of the algorithm design, do not write a long formula with multiple variables, -                 //each variable that is to be Bashi is named separately, and then debugging can detect which variable is the problem $                 //int itemp = Convert.ToInt32 (Decimalspart[i]. ToString ()); $  -temp =Decimalspart[i]; -  the                 //determine if decimalspart[i] is a letter -                 if(Char. Isletter (temp))Wuyi                 { the                     if(Char. Isupper (temp)) -                     { WuTemp =convert.tochar (Convert.ToInt32 (temp) + +); -  About                     } $                     //if it's a letter, use a dictionary to convert it. -Sumofdecimalspart + = convert.todouble (tableof16_10[temp] * MATH.POW ( -,-(i +1))); -                 } -                 Else A                 { +                     //if it's not a normal letter , theSumofdecimalspart + = convert.todouble (Convert.ToInt32 (decimalspart[i). ToString ()) * MATH.POW ( -,-(i +1))); -                 } $                  the             } the  the  the             intSumofintegerpart =0; -              for(inti =0; i < integerpart.length; i++) in             { the                 //Decimalspart[i] is a char type, so add a ToString the                 //in the initial stage of the algorithm design, do not write a long formula with multiple variables, About                 //each variable that is to be Bashi is named separately, and then debugging can detect which variable is the problem the                 //int itemp = Convert.ToInt32 (Decimalspart[i]. ToString ()); thetemp =Integerpart[i]; the                 //determine if decimalspart[i] is a letter +                 if(Char. Isletter (temp)) -                 { the                     if(Char. Isupper (temp))Bayi                     { thetemp = Convert.tochar (Convert.ToInt32 (temp) + +); the  -                     } -                     //if it's a letter, convert it to lowercase, then use a dictionary to convert theSumofintegerpart + = Convert.ToInt32 (tableof16_10[Char. ToLower (temp)] * MATH.POW ( -, i)); the                 } the                 Else the                 { -                     //if it's not a normal letter , theSumofintegerpart + = Convert.ToInt32 (Convert.ToInt32 (integerpart[i). ToString ()) * MATH.POW ( -, i)); the                 } the             }94  the  theConsole.Write ("Decimalspart:"); the Console.WriteLine (decimalspart);98  AboutConsole.Write ("Sumofdecimalspart:"); - Console.WriteLine (sumofdecimalspart);101 102Console.Write ("Integerpart:");103 Console.WriteLine (integerpart);104  theConsole.Write ("Sumofintegerpart:");106 Console.WriteLine (sumofintegerpart);107 108Console.Write ("Result:");109  the             //This is a concatenation of integers and fractional parts.111Console.WriteLine (Sumofintegerpart+sumofdecimalspart.tostring (). Substring (1)); the Console.readkey ();113         } the     } the}

2 Show1

Show2

C # console base unsigned hexadecimal decimal conversion to decimal

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.