Kotlin, to get the float result

To get float result in Kotlin, you have to define the float type for your Intiger first

fun main() {
var num1: Double = 8.0
var num2: Double = 34.0
var num3: Double = num2 / num1
println(num1 + num2)
println(num2 – num1)
println(num1 * num2)
println(num2 % num1)
println(num2 / num1)
}

在Kotlin中,如果你想得到小数的计算结果,你需要首先把整数定义成为小数

0 0 votes
Article Rating

You may also like...

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x