Help Convert Signed Decimal Number to Binary and Vice Versa
Greetings, I understand how to convert positive decimals to binary and vice versa, but I am not quite sure how to go about factoring in negative numbers with their binary equivalents. It must be 8 bits (therefore, the decimal outputs must range from -128 to 127). Please help!
PS: I am not allowed to use toBinaryString for reasons unstated.
Re: Help Convert Signed Decimal Number to Binary and Vice Versa
Quote:
how to convert positive decimals to binary
You can use an assignment statement to copy a value in an int variable to a byte variable by casting it.
Or are you talking about converting a String of decimal digit (0-9) characters to a String of binary digit (0-1) characters?