Tag: bigdecimal

为什么Kotlin没有十进制?

最近我遇到了一个问题迭代十进制数十进制的步骤,我很奇怪,为什么Kotlin只有Int , Long和Char Progressions。 我明白,可能会有一些小数点的警告。 但仍然。 我们只想开始BigDecimal数字,结束BigDecimal数字,然后用BigDecimal步骤遍历它们。 问:那么,为什么没有整数的进步呢? 谢谢。 PS:这是一个可能实现的示例代码(我把Int来源和适应BigDecimal ): /** * Returns a progression that goes over the same range with the given step. */ public infix fun BigDecimalProgression.step(step: BigDecimal): BigDecimalProgression { if (step <= java.math.BigDecimal.ZERO) throw IllegalArgumentException("Step must be positive, was: $step.") return BigDecimalProgression.fromClosedRange(first, last, if (this.step > java.math.BigDecimal.ZERO) step else -step) […]