Is there a good way to convert a integer to a 2's complement binary and store the result as a String? In the Integer class there is a static method toBinaryString(int i) but it only handles "unsigned" integers. How do I do it with signed integers?
US Constitution Article II, Section 1, Paragraph 7
"The President shall, at stated Times, receive for his Services, a Compensation, which shall neither be encreased nor diminished during the Period for which he shall have been elected, and he shall not receive within that Period any other Emolument from the United States, or any of them."
and Article I, Section 9, Paragraph 8
"No Title of Nobility shall be granted by the United States: And no Person holding any Office of Profit or Trust under them, shall, without the Consent of the Congress, accept of any present, Emolument, Office, or Title, of any kind whatever, from any King, Prince, or foreign State."
e·mol·u·ment: a salary, fee, or profit from employment or office.
Just saying.
Question
NtOrZor
Is there a good way to convert a integer to a 2's complement binary and store the result as a String? In the Integer class there is a static method toBinaryString(int i) but it only handles "unsigned" integers. How do I do it with signed integers?
Link to comment
https://www.neowin.net/forum/topic/223959-javaconverting-integer-to-signed-binary/Share on other sites
9 answers to this question
Recommended Posts