Skip to content

Instantly share code, notes, and snippets.

@s1monw1
Created September 20, 2022 22:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save s1monw1/e0a836971e34b1f24d90cb3b36c9d027 to your computer and use it in GitHub Desktop.
Save s1monw1/e0a836971e34b1f24d90cb3b36c9d027 to your computer and use it in GitHub Desktop.
/**
* 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