小喵 🐈 says to YSITDfun Double.toHumanReadable(unitA: String, unitB: String): String { val isScaled = this >= 800 val value = if (isScaled) this / 1000 else this val unit = if(isScaled) unitB else unitA val str = if (this < 10) "%.1f%s" else "%.0f%s" return str.format(str, unit) } fun main() { val n: Double = 9487.87 println(n.toHumanReadable(" m", " km")) // "9.4 km" }at Thu, Mar 1, 2018 7:45 PM