Is there any reason why Kotlin chooses Double as default type for decimals over Float?
c
Casey Brooks
10/22/2019, 6:23 PM
1) Because Kotlin is strongly inspired by Java, and Java uses Doubles for decimal literals
2) are there any other modern languages that use Float by default instead of Double? I can’t think of any off the top of my head
t
tseisel
10/22/2019, 6:39 PM
IMHO, the only advantage for using Float over Double is that they use 2 times less memory. But you may prefer precise calculations to using less memory, even when running on a basic Android phone with 1 Go of RAM.
c
Casey Brooks
10/22/2019, 6:45 PM
That amount of memory would be negligible for most applications. It’s much more practical to assume that large numbers are a more likely problem than running out of memory on todays computers.
b
bjonnh
10/22/2019, 6:47 PM
python calls it float, but it is double
k
karelpeeters
10/22/2019, 8:45 PM
No, they're both floating point, the 32 bit/64 bits versions are called single and double precision.