Logo

Programming-Idioms

History of Idiom 76 > diff from v2 to v3

Edit summary for version 3 by :

Version 2

2015-08-21, 13:37:44

Version 3

2015-08-21, 13:38:27

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/6Bz5w2RCIt