Logo

Programming-Idioms

History of Idiom 76 > diff from v34 to v35

Edit summary for version 35 by :
[Go]+DocURL to strconv.FormatInt

Version 34

2015-12-30, 13:57:44

Version 35

2015-12-30, 13:58:32

Idiom #76 Binary digits from an integer

Create the string s of integer x written in base 2.

E.g. 13 -> "1101"

Idiom #76 Binary digits from an integer

Create the string s of integer x written in base 2.

E.g. 13 -> "1101"

Imports
import "strconv"
Imports
import "strconv"
Code
s := strconv.FormatInt(x, 2)
Code
s := strconv.FormatInt(x, 2)
Comments bubble
Here x has type int64.

For very big numbers, prefer type *big.Int.
Comments bubble
Here x has type int64.

For very big numbers, prefer type *big.Int.
Doc URL
https://golang.org/pkg/strconv/#FormatInt
Origin
http://stackoverflow.com/a/13870865/871134
Origin
http://stackoverflow.com/a/13870865/871134
Demo URL
http://play.golang.org/p/Puc5oe4Lv5
Demo URL
http://play.golang.org/p/Puc5oe4Lv5