Created
March 24, 2022 20:48
-
-
Save Deleplace/26ab45656d0e4cf10c23714bda6bae58 to your computer and use it in GitHub Desktop.
Format integer with zero-padding
This file contains hidden or 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
| void main() { | |
| { | |
| var i = 0; | |
| var s = i.toString().padLeft(3,'0'); | |
| print(s); | |
| } | |
| { | |
| var i = 7; | |
| var s = i.toString().padLeft(3,'0'); | |
| print(s); | |
| } | |
| { | |
| var i = 42; | |
| var s = i.toString().padLeft(3,'0'); | |
| print(s); | |
| } | |
| { | |
| var i = 208; | |
| var s = i.toString().padLeft(3,'0'); | |
| print(s); | |
| } | |
| { | |
| var i = 1515; | |
| var s = i.toString().padLeft(3,'0'); | |
| print(s); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment