Created
November 4, 2012 14:56
-
-
Save jimjh/4012189 to your computer and use it in GitHub Desktop.
Padding with sprintf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
// make sure that printf pads digits with zeros so we can sort the strings | |
// without converting to them back to ints | |
fmt.Printf("%010d\n", 1) | |
fmt.Printf("%010d\n", 15) | |
fmt.Printf("%010d\n", 250) | |
fmt.Printf("%010d\n", 2560) | |
fmt.Printf("%010d\n", 34234) | |
fmt.Printf("%010d\n", 444444) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment