https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
d

Daniel

03/03/2023, 9:08 PM
Hello, How to convert a normal double in Kotlin to Swiftui? I have this double in kotlin with 7 decimals: 47.6364658. But the swift will convert automatically to 47.636466 (only 6 decimals) How can I convert this?
j

Johann Pardanaud

03/04/2023, 11:35 AM
In Swift REPL I am able to create a double with 7 decimals. It seems like Kotlin is the one responsible for this erroneous conversion. To avoid any conversion issues, you could try to multiply your double by
10^7
, convert it to a Kotlin Int, then make the conversion to a Swift Int, and finally divide it by
10^7
.
10 Views