answersLogoWhite

0


Best Answer

if you're using Java the Integer class has alot of methods that can easely convert to byte

for example:

int s;

Integer i = new Integer (s);

i.byteValue() // returns the same number but as a byte

i.toBinaryString(s) // returns the binary value as a string varibale

otherwise you can construct a loop that constructs a varaible using isOdd and finction ex :

public int binaryVariable (int i){

int m = 1; // increments with each variables

int n = 0; // varies between 0 and 1;

int a =0; // the outcoming number;

while (i>0){

if (isOdd (i)) n =1; // I'm afraid you have to make the isOdd function

else n = 0;

a +=n*m;

m*=10;

i/=2;

}

return a;

}

//hope this has helped

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Program that accepts an input as a decimal number and converts it into a binary expression?
Write your answer...
Submit
Still have questions?
magnify glass
imp