我有一个包含2个值和1个运算符的列表。然后我这样做:
calcArray[1] == "+" -> {
result = (calcArray[0].toDouble() + calcArray[2].toDouble())
}
calcArray[1] == "-" -> {
result = (calcArray[0].toDouble() - calcArray[2].toDouble())
}
calcArray[1] == "*" -> {
result = (calcArray[0].toDouble() * calcArray[2].toDouble())
}
calcArray[1] == "/" -> {
result = (calcArray[0].toDouble() / calcArray[2].toDouble())
}
然后Kotlin做了
计算:0.2 * 6结果:1.2000000000000002
我还尝试了其他数字的周围,并再次出现错误
计算:0.2 * 3结果:0.6000000000000001