1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 14:12:56 +08:00

simplify format method

Co-authored-by: Bartłomiej Dach <dach.bartlomiej@gmail.com>
This commit is contained in:
cdwcgt 2023-05-27 23:44:50 +09:00 committed by GitHub
parent 89c8ef3c9b
commit a05312c9a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -96,11 +96,7 @@ namespace osu.Game.Graphics.UserInterface
if (DisplayAsPercentage)
{
if (significantDigits <= 2)
return floatValue.ToString("0%");
string format = "0." + new string('0', significantDigits - 2) + "%";
return floatValue.ToString(format);
return floatValue.ToString($@"P{Math.Max(0, significantDigits - 2)}");
}
string negativeSign = Math.Round(floatValue, significantDigits) < 0 ? "-" : string.Empty;