Skip to content

Commit e932f02

Browse files
committed
Tweak native formatting function
1 parent 4744dc1 commit e932f02

File tree

1 file changed

+4
-4
lines changed
  • runtime/nativeMain/src/org/jetbrains/gradle/benchmarks

1 file changed

+4
-4
lines changed

runtime/nativeMain/src/org/jetbrains/gradle/benchmarks/Utils.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ import platform.posix.*
55

66
actual fun Double.format(precision: Int): String {
77
val longPart = toLong()
8-
val fractional = this@format - longPart
8+
val fractional = this - longPart
99
val thousands = longPart.toString().replace(Regex("\\B(?=(\\d{3})+(?!\\d))"), ",")
10-
if (fractional == 0.0 || precision == 0)
10+
if (fractional < DBL_EPSILON || precision == 0)
1111
return thousands
12-
12+
1313
return memScoped {
1414
val bytes = allocArray<ByteVar>(100)
1515
sprintf(bytes, "%.${precision}F", fractional)
1616
val fractionText = bytes.toKString()
17-
return thousands + fractionText.removePrefix("0")
17+
thousands + fractionText.removePrefix("0")
1818
}
1919
}
2020

0 commit comments

Comments
 (0)