Skip to main content

Command Palette

Search for a command to run...

Numeral Systems - Binary

Updated
1 min readView as Markdown
Numeral Systems -  Binary
S
DevRel at StackGen | Formerly at Deepfence ,Tenable , Accurics | AWS Community Builder also Docker Community Award Winner at Dockercon2020 | CyberSecurity Innovator of Year 2023 award by Bsides Bangalore | Docker/HashiCorp Meetup Organiser Bangalore & Co-Author of Learn Lightweight Kubernetes with k3s (2019) , Packt Publication & also run Non Profit CloudNativeFolks / CloudSecCorner Community To Empower Free Education reach out me twitterhttps://twitter.com/sangamtwts or just follow on GitHub -> https://github.com/sangam14 for Valuable Resources
    package main

    import "fmt"

    func main() {
     fmt.Printf("%d - %b \n", 42, 42)
    }

Run{:.button.button--outline-success.button--pill}

Output:

 42 - 101010 

Program exited.

in above program the annotation verb %b formats a number in binary Ex:- which represent 101010 ( base 2 format) and the annotation verb %d formats a number in Base 10 Ex:which represent 42 ( base 10 format)

Integer cheatsheet for fmt

      %b    base 2
      %c    the character represented by the corresponding Unicode code point
      %d    base 10
      %o    base 8
      %q    a single-quoted character literal safely escaped with Go syntax.
      %x    base 16, with lower-case letters for a-f
      %X    base 16, with upper-case letters for A-F
      %U    Unicode format: U+1234; same as "U+%04
19 views

More from this blog

C

CloudNativeFolks Community

140 posts

CloudNativeFolks is non profit community that empower and educate about cloud native technology !