Fix no suffix being concated to formatted text
This commit is contained in:
parent
b6e57632a6
commit
e90e7b3793
@ -240,7 +240,7 @@ fun BigInteger.formatSi(decimalPlaces: Int = 2): String {
|
||||
|
||||
fun BigInteger.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2): Component {
|
||||
require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" }
|
||||
val prefix = determineSiPrefix() ?: return TextComponent(toString())
|
||||
val prefix = determineSiPrefix() ?: return if (suffix == "") TextComponent(toString(decimalPlaces)) else if (suffix is Component) TextComponent(toString(decimalPlaces) + suffix.string) else TextComponent(toString(decimalPlaces) + suffix)
|
||||
val isNegative = isNegative
|
||||
val arr = (if (isNegative) -this else this).divideAndRemainder(prefix.integer)
|
||||
val divided = arr[0].toString()
|
||||
@ -320,7 +320,7 @@ fun ImpreciseFraction.formatSi(decimalPlaces: Int = 2): String {
|
||||
|
||||
fun ImpreciseFraction.formatSiComponent(suffix: Any = "", decimalPlaces: Int = 2): Component {
|
||||
require(decimalPlaces >= 0) { "Invalid amount of decimal places required: $decimalPlaces" }
|
||||
val prefix = determineSiPrefix() ?: return TextComponent(toString(decimalPlaces))
|
||||
val prefix = determineSiPrefix() ?: return if (suffix == "") TextComponent(toString(decimalPlaces)) else if (suffix is Component) TextComponent(toString(decimalPlaces) + " " + suffix.string) else TextComponent(toString(decimalPlaces) + " " + suffix)
|
||||
return TranslatableComponent(prefix.formatLocaleKey, (this / prefix.impreciseFraction).toString(decimalPlaces), suffix)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user