Skip to content

Commit

Permalink
Fix Binary to Hexadecimal Does Not Support Zeroes Only Issue
Browse files Browse the repository at this point in the history
  • Loading branch information
kentlouisetonino committed May 8, 2024
1 parent 6054ed9 commit b0679fa
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 b0679fa

Please sign in to comment.