Change Duration.toString(unit, decimals) formatting
- switch to scientific notation when value is too big (greater than 1e14) - allow at most 12 decimals, larger values are coerced to 12 - use scientific format with exactly two decimals in mantissa in JVM
This commit is contained in:
@@ -34,4 +34,4 @@ internal actual fun formatUpToDecimals(value: Double, decimals: Int): String =
|
||||
|
||||
private val scientificFormat = ThreadLocal<DecimalFormat>()
|
||||
internal actual fun formatScientific(value: Double): String =
|
||||
scientificFormat.getOrSet { DecimalFormat("0E0", rootFormatSymbols).apply { maximumFractionDigits = 2 } }.format(value)
|
||||
scientificFormat.getOrSet { DecimalFormat("0E0", rootFormatSymbols).apply { minimumFractionDigits = 2 } }.format(value)
|
||||
Reference in New Issue
Block a user