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

Add hexadecimal to binary and hexadecimal to decimal conversions #1328

Merged
merged 4 commits into from May 25, 2020

Conversation

@MohamedBechir
Copy link
Contributor

@MohamedBechir MohamedBechir commented May 25, 2020

I have noticed that some conversions are missing, so I started by adding the hexadecimal to decimal and the hexadecimal to binary ones, if you approve it I can work on the other ones.
My code converts a hexadecimal number to a decimal one.

NB: I am new to the software engineering community. I did my best and if anything is wrong with my code I can change it anytime, I am eager to learn more.

@MohamedBechir MohamedBechir changed the title Add HexadecimalToDecimal conversion Add HexadecimalToBinary conversion May 25, 2020
@MohamedBechir MohamedBechir changed the title Add HexadecimalToBinary conversion Add hexadecimal to decimal conversion May 25, 2020
@MohamedBechir MohamedBechir changed the title Add hexadecimal to decimal conversion Add hexadecimal to binary conversion May 25, 2020
Copy link
Contributor Author

@MohamedBechir MohamedBechir left a comment

I am sorry the first commit is hexadecimal to decimal conversion and the second one is hexadecimal to binary conversion ( the second commit message is false)
Sorry again

@MohamedBechir MohamedBechir changed the title Add hexadecimal to binary conversion Add hexadecimal to binary and hexadecimal to decimal conversions May 25, 2020
@MohamedBechir MohamedBechir force-pushed the MohamedBechir:Development branch from 40c192c to 724ff7e May 25, 2020
package com.conversions;

public class HexadecimalToBinary {
/**

This comment has been minimized.

@deadshotsb

deadshotsb May 25, 2020
Member

Your code fails in case of floating point conversion, 'ABC.BC' try doing it for real values also

This comment has been minimized.

@deadshotsb

deadshotsb May 25, 2020
Member

Good work but you missed out in the 2nd file.

@MohamedBechir
Copy link
Contributor Author

@MohamedBechir MohamedBechir commented May 25, 2020

@deadshotsb Okay, thank you for your feedback I will fix it now.

@MohamedBechir
Copy link
Contributor Author

@MohamedBechir MohamedBechir commented May 25, 2020

@deadshotsb I have just fixed the requested changes can you check it and give me your feedback?
Thank you

package com.conversions;

public class HexadecimalToBinary {
/**

This comment has been minimized.

@deadshotsb

deadshotsb May 25, 2020
Member

Good work but you missed out in the 2nd file.

* @return decimal number
*/
public String hexToDecimal(String hexaStr) {
String hexaNumbers = "0123456789ABCDEF";

This comment has been minimized.

@deadshotsb

deadshotsb May 25, 2020
Member

Your code fails in case of "AB.CD"

This comment has been minimized.

@nippur101

nippur101 May 26, 2020

because from the point you must multiply for 1/16, the potency start to be negative

This comment has been minimized.

@MohamedBechir

MohamedBechir May 26, 2020
Author Contributor

@nippur101
Yes, that's what I did, thank you

@MohamedBechir
Copy link
Contributor Author

@MohamedBechir MohamedBechir commented May 25, 2020

@deadshotsb you are right sir, I'll do it now! Sorry

@deadshotsb
Copy link
Member

@deadshotsb deadshotsb commented May 25, 2020

@MohamedBechir We are all developers no sir and boss please

@MohamedBechir
Copy link
Contributor Author

@MohamedBechir MohamedBechir commented May 25, 2020

@deadshotsb can you explain more what I am supposed to do? A.B => 10.11 or A.B => 10.6875? thank you

@deadshotsb
Copy link
Member

@deadshotsb deadshotsb commented May 25, 2020

A.B = 16^(0)*(10) + 16^(-1) * (11)

@MohamedBechir
Copy link
Contributor Author

@MohamedBechir MohamedBechir commented May 25, 2020

@deadshotsb I just fixed it, take a look. Thank you again

@deadshotsb deadshotsb merged commit 9f8abb0 into TheAlgorithms:Development May 25, 2020
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

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