answersLogoWhite

0

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

14y ago

What else can I help you with?