Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upconversion binary to hexadecimal #694
Conversation
* @return The hexadecimal number | ||
*/ | ||
|
||
public String binToHex(int binary) { |
yanglbme
Jan 28, 2019
Member
The binary number may have 32bits or 64bits, so it's unsuitable to use int
type.
public void testBinaryToHexadecimal(){ | ||
BinaryToHexadecimal binaryToHexadecimal = new BinaryToHexadecimal(); | ||
Assert.assertEquals("Incorrect Conversion", "2A", binaryToHexadecimal.binToHex(101010)); | ||
Assert.assertEquals("Incorrect Conversion", "24", binaryToHexadecimal.binToHex(100100)); |
yanglbme
Jan 28, 2019
Member
How about the test case 1010101010101010101010101010101010101010101010101010101010101010101010100001
(64 bits)
@arodriguez33 Thanks for your changes :) |
conversion binary to hexadecimal