数学计算, 用于结果 Number为null 时无法计算的问题
函数 | 案例 | 结果 |
---|---|---|
scale2(makeup: Boolean = true): String | val a: String = 12.13124123.scale2() val b: String = 12.10.scale2() val c: String = 12.00.scale2() val d: String = 12.456.scale2() val a1: String = 12.13124123.scale2(false) val b1: String = 12.10.scale2(false) val c1: String = 12.00.scale2(false) val d1: String = 12.456.scale2(false) |
a = 12.13 b = 12.10 c = 12.00 d = 12.46 a1 = 12.13 b1 = 12.1 c1 = 12 d1 = 12.46 |
add(num: Double): Double | val add: Double = 1.1.add(3.0) | add = 1.1 + 3.0 |
subtract(num: Double): Double | val subtract: Double = 1.1.subtract(3.0) | subtract = 1.1 - 3.0 |
multiply(num: Double): Double | val multiply: Double = 1.1.multiply(3.0) | multiply = 1.1 * 3.0 |
divide(num: Double): Double | val divide: Double = 1.1.divide(3.0) | divide = 1.1 / 3.0 |