Browse Source

Binary to decimal & vice versa now works

test
lLewdie 1 year ago
parent
commit
86fb10a334
  1. 24
      num-converter/WebForm1.aspx.cs

24
num-converter/WebForm1.aspx.cs

@ -16,7 +16,31 @@ namespace num_converter
protected void btnConvert_Click(object sender, EventArgs e)
{
String Result = string.Empty;
int Remainder;
int DecimalNum;
int BinaryNum;
int OctalNum;
int Base1 = 1;
if (ddlSourcePosNum.SelectedIndex == 1 && ddlTargetPosNum.SelectedIndex == 2)
{
DecimalNum = Convert.ToInt32(txtInput.Text);
while (DecimalNum > 0)
{
Remainder = DecimalNum % 2;
DecimalNum /= 2;
Result = Remainder.ToString() + Result;
}
lblResult.Text = Result;
}
if (ddlSourcePosNum.SelectedIndex == 2 && ddlTargetPosNum.SelectedIndex == 1)
{
BinaryNum = Convert.ToInt32(txtInput.Text, 2);
Result = BinaryNum.ToString();
lblResult.Text = Result;
}
}
protected void btnClear_Click(object sender, EventArgs e)

Loading…
Cancel
Save