Skip to content

Commit

Permalink
Merge pull request #9 from kentlouisetonino/fix/binary-to-hexadecimal…
Browse files Browse the repository at this point in the history
…-does-not-support-zeroes-only

fix: Binary to Hexadecimal Does Not Support Zeroes Only Issue
  • Loading branch information
kentlouisetonino committed May 8, 2024
2 parents 6054ed9 + b0679fa commit e879f07
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/services/binary/get_binary_to_hexadecimal.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
package binary

import "strconv"
import (
"strconv"
)

// Converts binary number to hexadecial.
func getBinaryToHexadecimal(binary int64) string {
hexadecimal := ""
reversedBinaryArray := getReversedBinaryArray(binary)
arrayOfHexadecimal := []int64{}
groupSum := int64(0)

if binary == 0 {
return "0"
}

for i := 0; i < len(reversedBinaryArray); i++ {
numWeight := i % 4
isLastIndex := i == (len(reversedBinaryArray) - 1)
Expand Down

0 comments on commit e879f07

Please sign in to comment.