Logo

Programming-Idioms

History of Idiom 76 > diff from v4 to v5

Edit summary for version 5 by :

Version 4

2015-08-21, 13:45:32

Version 5

2015-08-21, 13:46:48

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.
Origin
http://stackoverflow.com/a/13870865/871134
Origin
http://stackoverflow.com/a/13870865/871134
Demo URL
http://play.golang.org/p/6Bz5w2RCIt
Demo URL
http://play.golang.org/p/Puc5oe4Lv5