Created
September 20, 2022 22:25
-
-
Save s1monw1/e0a836971e34b1f24d90cb3b36c9d027 to your computer and use it in GitHub Desktop.
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
/** | |
* parses string number into BigDecimal with a scale of 2 | |
*/ | |
fun parseNumber(number: String): BigDecimal { | |
return number.toBigDecimal().setScale(2, RoundingMode.HALF_UP) | |
} | |
fun main() { | |
println(parseNumber("100.12212")) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment