Skip to content

Commit

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

fix: Binary to Octal Does Not Support Zeroes Only
  • Loading branch information
kentlouisetonino authored May 8, 2024
2 parents 0b73958 + fd51e76 commit 6054ed9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/services/binary/get_binary_to_octal.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 octal.
func getBinaryToOctal(binary int64) string {
reversedBinaryArray := getReversedBinaryArray(binary)
octal := ""
arrayOfOctal := []int64{}
groupSum := int64(0)

if binary == 0 {
return "0"
}

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

0 comments on commit 6054ed9

Please sign in to comment.