package com.suno.android.common_ui.extensions import androidx.compose.runtime.Stable import java.text.NumberFormat import java.util.Locale @Stable @Suppress("MagicNumber") fun Int.xAsFormattedCount(): String = when { this >= 1_000 && this < 10_000 - 50 -> String.format(Locale.getDefault(), "%.1fK", this / 1_000.0) this >= 10_000 - 50 && this < 1_000_000 - 500 -> String.format(Locale.getDefault(), "%.0fK", this / 1_000.0) this >= 1_000_000 - 500 -> String.format(Locale.getDefault(), "%.1fM", this / 1_000_000.0) else -> String.format(Locale.getDefault(), "%.0f", this.toDouble()) } @Stable fun Int.xAsFormattedNumberInstance(): String = NumberFormat.getNumberInstance(Locale.getDefault()).format(this)