From ff79a11e5689acd753214f699f6f7a9e359bb444 Mon Sep 17 00:00:00 2001 From: lLewdie Date: Fri, 22 Sep 2023 15:15:18 -0500 Subject: [PATCH] Decimal done --- num-converter/WebForm1.aspx | 36 ++++++++++++++----------- num-converter/WebForm1.aspx.cs | 31 +++++++++++++++++++++ num-converter/WebForm1.aspx.designer.cs | 9 ------- 3 files changed, 51 insertions(+), 25 deletions(-) diff --git a/num-converter/WebForm1.aspx b/num-converter/WebForm1.aspx index 5b037e9..ef8075a 100644 --- a/num-converter/WebForm1.aspx +++ b/num-converter/WebForm1.aspx @@ -9,6 +9,16 @@ .auto-style1 { width: 100%; } + .auto-style2 { + height: 30px; + } + .auto-style3 { + width: 284px; + } + .auto-style4 { + height: 30px; + width: 284px; + } @@ -27,19 +37,20 @@ + + + + - - - - - - - - - - - -
+ Source Positional System + Target Positional System
Select An Option Decimal Binary - Octal - Hexadecimal - - + Select An Option Decimal @@ -50,28 +61,21 @@
+   +
+  
   
diff --git a/num-converter/WebForm1.aspx.cs b/num-converter/WebForm1.aspx.cs index f08bcd6..f2f13f4 100644 --- a/num-converter/WebForm1.aspx.cs +++ b/num-converter/WebForm1.aspx.cs @@ -34,6 +34,37 @@ namespace num_converter } lblResult.Text = Result; } + + if (ddlSourcePosNum.SelectedIndex == 1 && ddlTargetPosNum.SelectedIndex == 3) + { + + DecimalNum = Convert.ToInt32(txtInput.Text); + while (DecimalNum > 0) + { + Remainder = DecimalNum % 8; + Result = Remainder.ToString() + Result; + DecimalNum /= 8; + } + + lblResult.Text = "0x" + Result; + + } + + if (ddlSourcePosNum.SelectedIndex == 1 && ddlTargetPosNum.SelectedIndex == 4) + { + DecimalNum = Convert.ToInt32(txtInput.Text); + while (DecimalNum > 0) + { + Remainder = DecimalNum % 16; + string hexDigit = (Remainder < 10) + ? Remainder.ToString() + : ((char)('A' + Remainder - 10)).ToString(); + Result = hexDigit + Result; + DecimalNum /= 16; + } + + lblResult.Text = Result; + } if (ddlSourcePosNum.SelectedIndex == 2 && ddlTargetPosNum.SelectedIndex == 1) { BinaryNum = Convert.ToInt32(txtInput.Text, 2); diff --git a/num-converter/WebForm1.aspx.designer.cs b/num-converter/WebForm1.aspx.designer.cs index 8e0c7a7..62cd546 100644 --- a/num-converter/WebForm1.aspx.designer.cs +++ b/num-converter/WebForm1.aspx.designer.cs @@ -32,15 +32,6 @@ namespace num_converter /// protected global::System.Web.UI.WebControls.DropDownList ddlSourcePosNum; - /// - /// Label1 control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Label Label1; - /// /// ddlTargetPosNum control. ///