Last active
April 27, 2023 11:04
-
-
Save shakir915/853a1af16ad579d0c48223c536ecf57e to your computer and use it in GitHub Desktop.
trim end zeros
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
import java.util.* | |
var array= arrayOf( | |
1.00, | |
1.01, | |
1.11, | |
1.10, | |
1.00111, | |
1.01111, | |
1.11111, | |
1.10111, | |
1.toDouble(), | |
) | |
array.forEach { | |
println( | |
String.format(Locale.ENGLISH,"%.2f",it).trimEnd('0').trimEnd('.') | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
1
1.01
1.11
1.1
1
1.01
1.11
1.1
1