Home > Net >  Decimal conversion of binary console converter at vb.net
Decimal conversion of binary console converter at vb.net

Time:11-17

I am a beginner vb.net, and now are trying to do a decimal conversion of binary complement the console program

'turn decimal binary step is to decimal number divided by two ran until the quotient is 0, then read the remainder, could you tell me how to get to remainder?

'how to make the program automatically if the input Numbers of positive and negative to determine a radix-minus-one complement whether need to zero is a 1, will be to zero?

'how to binary addition and subtraction

Thank you

The following is my train of thought:

Determine the number of plus or minus

The original decimal number divided by two until the quotient is 0

Read the remainder (into the original code)

Will be negative to the original code 0 and 1, 1-0 (into radix-minus-one complement)

+ 1 (for binary addition radix-minus-one complement to complement)

Wrong direction may be great god bosses laughed to obtain more

CodePudding user response:

The original problem: Create a program in VB that reads a whole decimal number from the the rid_device_info_keyboard and converts it to binary in two 's complement form. The user also specifies the number of bits to use.

CodePudding user response:

Judge whether a number is negative is very easy to compare whether less than zero,

CodePudding user response:

Decimal to binary:
 
Dim a=47, er=0
While a & gt; 0
Er=a Mod 2
A -=er
A/=2
The Console. Write (er)
End While
Console. WriteLine (0)

CodePudding user response:

Me. The Text=the Convert. ToString (111, 2)
  • Related