louiscad
03/17/2023, 4:11 PMprint(0.0.toString())
prints 0.0
on the JVM, but 0
on JS.
Is there an alternative to toString()
to get 0.0
on JS as well?ephemient
03/17/2023, 4:43 PMephemient
03/17/2023, 4:44 PMephemient
03/17/2023, 4:49 PMfun Double.toStringInFloatingPointNotation(): String {
val string = toString()
return if ('.' in string || 'e' in string || !isFinite()) string else "$string.0"
}