decimal_to_binary

command
v0.0.0-...-9d64b2e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 25, 2021 License: MIT Imports: 1 Imported by: 0

README

Binary representation of a given number

Source: GeeksforGeeks Write a program to print Binary representation of a given number.

Algorithm

Recursive using bitwise operator

  • Check n > 1
  • right shift the number by 1 bit and recursive call the function
  • Print the bits of number

Alternate solution is to use fmt Go package to transform decimal to binary:

fmt.Printf("The binary of the %d is: %b\n", x, x)

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL