Logo

Programming-Idioms

History of Idiom 55 > diff from v25 to v26

Edit summary for version 26 by :

Version 25

2015-10-22, 08:48:30

Version 26

2015-10-29, 14:05:14

Idiom #55 Convert integer to string

Create the string representation s (in radix 10) of integer value i.

Idiom #55 Convert integer to string

Create the string representation s (in radix 10) of integer value i.

Imports
import "strconv"
Imports
import "strconv"
Code
s := strconv.FormatInt(i, 10)
Code
s := strconv.FormatInt(i, 10)
Comments bubble
When i has type int64.
Comments bubble
When i has type int64.
Doc URL
https://golang.org/pkg/strconv/#FormatInt
Doc URL
https://golang.org/pkg/strconv/#FormatInt
Demo URL
http://play.golang.org/p/TE06SqU2Sc
Demo URL
http://play.golang.org/p/TE06SqU2Sc
Code
s = str(i)
Code
s = str(i)
Code
let s = format!("{}", i);
Code
let s = format!("{}", i);
Doc URL
http://doc.rust-lang.org/std/fmt/index.html
Doc URL
http://doc.rust-lang.org/std/fmt/index.html
Demo URL
https://play.rust-lang.org/?code=fn%20main()%20%7B%0A%20%20%20%20let%20i%20%3D%2042%3B%0A%20%20%20%20let%20s%20%3D%20format!(%22%7B%7D%22%2C%20i)%3B%0A%20%20%20%20%0A%20%20%20%20println!(%22%7B%7D%22%2C%20s)%3B%0A%7D%0A&version=stable
Demo URL
https://play.rust-lang.org/?code=fn%20main()%20%7B%0A%20%20%20%20let%20i%20%3D%2042%3B%0A%20%20%20%20let%20s%20%3D%20format!(%22%7B%7D%22%2C%20i)%3B%0A%20%20%20%20%0A%20%20%20%20println!(%22%7B%7D%22%2C%20s)%3B%0A%7D%0A&version=stable
Code
String s=((Integer)i).toString();
Code
String s=((Integer)i).toString();
Imports
import "strconv"
Imports
import "strconv"
Code
s := strconv.Itoa(i)
Code
s := strconv.Itoa(i)
Comments bubble
When i has type int.
Comments bubble
When i has type int.
Doc URL
https://golang.org/pkg/strconv/#Itoa
Doc URL
https://golang.org/pkg/strconv/#Itoa
Origin
http://stackoverflow.com/a/10105983/871134
Origin
http://stackoverflow.com/a/10105983/871134
Demo URL
http://play.golang.org/p/An5ev_G8rS
Demo URL
http://play.golang.org/p/An5ev_G8rS