// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; using Humanizer; namespace osu.Game.Utils { public static class FormatUtils { /// /// Turns the provided accuracy into a percentage with 2 decimal places. /// /// The accuracy to be formatted /// formatted accuracy in percentage public static string FormatAccuracy(this double accuracy) { // we don't ever want to show 100% when the accuracy is below perfect, even if it rounds to 100%. if (accuracy < 1 && accuracy > 0.9999) accuracy = 0.9999; return $"{accuracy:0.00%}"; } /// /// Formats the supplied rank/leaderboard position in a consistent, simplified way. /// /// The rank/position to be formatted. public static string FormatRank(this int rank) => rank.ToMetric(decimals: rank < 100_000 ? 1 : 0); } }