Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

conversion binary to hexadecimal #694

Merged
merged 5 commits into from Jan 30, 2019

Conversation

@arodriguez33
Copy link

@arodriguez33 arodriguez33 commented Jan 27, 2019

conversion binary to hexadecimal

* @return The hexadecimal number
*/

public String binToHex(int binary) {

This comment has been minimized.

@yanglbme

yanglbme Jan 28, 2019
Member

The binary number may have 32bits or 64bits, so it's unsuitable to use int type.

This comment has been minimized.

public void testBinaryToHexadecimal(){
BinaryToHexadecimal binaryToHexadecimal = new BinaryToHexadecimal();
Assert.assertEquals("Incorrect Conversion", "2A", binaryToHexadecimal.binToHex(101010));
Assert.assertEquals("Incorrect Conversion", "24", binaryToHexadecimal.binToHex(100100));

This comment has been minimized.

@yanglbme

yanglbme Jan 28, 2019
Member

How about the test case 1010101010101010101010101010101010101010101010101010101010101010101010100001 (64 bits)

This comment has been minimized.

@arodriguez33

arodriguez33 Jan 29, 2019
Author

Hi, i had to use BigInteger to resolve that case you commented.

arodriguez33 and others added 3 commits Jan 29, 2019
Copy link
Member

@yanglbme yanglbme left a comment

@arodriguez33 Thanks for your changes :)

@yanglbme yanglbme merged commit fe277cf into TheAlgorithms:Development Jan 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.