mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Add FormatUtils.FormatAccuracy and usages
This commit is contained in:
21
osu.Game/Utils/FormatUtils.cs
Normal file
21
osu.Game/Utils/FormatUtils.cs
Normal file
@ -0,0 +1,21 @@
|
||||
namespace osu.Game.Utils
|
||||
{
|
||||
public static class FormatUtils
|
||||
{
|
||||
/// <summary>
|
||||
/// Turns the provided accuracy into a percentage with 2 decimal places.
|
||||
/// Omits all decimal places when <paramref name="accuracy"/> equals 1d.
|
||||
/// </summary>
|
||||
/// <param name="accuracy">The accuracy to be formatted</param>
|
||||
/// <returns>formatted accuracy in percentage</returns>
|
||||
public static string FormatAccuracy(this double accuracy) => accuracy == 1 ? "100%" : $"{accuracy:0.00%}";
|
||||
|
||||
/// <summary>
|
||||
/// Turns the provided accuracy into a percentage with 2 decimal places.
|
||||
/// Omits all decimal places when <paramref name="accuracy"/> equals 100m.
|
||||
/// </summary>
|
||||
/// <param name="accuracy">The accuracy to be formatted</param>
|
||||
/// <returns>formatted accuracy in percentage</returns>
|
||||
public static string FormatAccuracy(this decimal accuracy) => accuracy == 100 ? "100%" : $"{accuracy:0.00}%";
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user