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

Added Hexadecimal To Decimal Conversion #657

Merged
merged 4 commits into from
Jan 10, 2024

Conversation

Adin3
Copy link
Contributor

@Adin3 Adin3 commented Jan 10, 2024

Added Hexadecimal to Decimal Conversion

the function takes a string slice that represents the hexadecimal number in string format and returns Result<u64, &`static str>

The function checks if the string slice is either empty or contains characters that cannot represent a hexadecimal number. In this case, the function will exit with Result::Err(error_message)

the function uses u64::from_str_radix() for the conversion of &str in base 16 to an u64.

If the function succeeds, it returns Result::Ok(decimal_number)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Fixed one line in bingo_sort after a warning was caught by `cargo clippy --all -- -D warnings
  • (checked afterward the unit tests, and everything was alright)
  • New feature (non-breaking change which adds functionality)
  • Added Hexadecimal To Decimal Conversion

Checklist:

  • I ran bellow commands using the latest version of rust nightly.
  • I ran cargo clippy --all -- -D warnings just before my last commit and fixed any issue that was found.
  • I ran cargo fmt just before my last commit.
  • I ran cargo test just before my last commit and all tests passed.
  • I added my algorithm to the corresponding mod.rs file within its own folder, and in any parent folder(s).
  • I added my algorithm to DIRECTORY.md with the correct link.
  • I checked COUNTRIBUTING.md and my code follows its guidelines.

@codecov-commenter
Copy link

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (cb3b21d) 94.57% compared to head (6d4bbaf) 94.62%.
Report is 3 commits behind head on master.

Files Patch % Lines
src/conversions/hexadecimal_to_decimal.rs 97.87% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #657      +/-   ##
==========================================
+ Coverage   94.57%   94.62%   +0.04%     
==========================================
  Files         285      287       +2     
  Lines       22906    22999      +93     
==========================================
+ Hits        21664    21762      +98     
+ Misses       1242     1237       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@siriak siriak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@Adin3 Adin3 requested a review from vil02 as a code owner January 10, 2024 20:48
@siriak siriak merged commit 83702a8 into TheAlgorithms:master Jan 10, 2024
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants