+ 3

How i get only Integer Part of number if the decimal part = 0 in Kotlin ?

Exemple : x = 300.0 i want print 300 but if = 300.54 i want print 300.54.

12th Jan 2022, 1:22 PM
Ahmed Seddiki
1 Answer
+ 7
//try this var x = 300.0 // or 300.54 if(x%1==0.0){ println(x.toInt()) } else { println(x) }
12th Jan 2022, 2:06 PM
Simba
Simba - avatar