From 1f026fd2e1af90eb5a69ece015d4ce4331ea7c70 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Tue, 28 Dec 2021 23:46:46 +0700 Subject: [PATCH] Add zeroing argument to percentage --- src/main/kotlin/ru/dbotthepony/mc/otm/core/Fraction.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Fraction.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Fraction.kt index 7ebdca0a7..598cec5c2 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/core/Fraction.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/core/Fraction.kt @@ -581,7 +581,8 @@ data class Fraction @JvmOverloads constructor(@JvmField val value: BigInteger, @ } // Позволяет получить процент от деления данного на divisor с точностью до 5 цифр - fun percentage(divisor: Fraction): Float { + fun percentage(divisor: Fraction, zeroing: Boolean = true): Float { + if (divisor.isZero() && zeroing) return 0f if (isNaN() || divisor.isNaN()) return Float.NaN val mul = (this * TEN_THOUSAND) / divisor