// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. namespace osu.Game.Utils { public static class FormatUtils { /// /// Turns the provided accuracy into a percentage with 2 decimal places. /// /// The accuracy to be formatted /// Whether to show decimal places if equals 1d /// formatted accuracy in percentage public static string FormatAccuracy(this double accuracy, bool alwaysShowDecimals = false) => accuracy == 1 && !alwaysShowDecimals ? "100%" : $"{accuracy:0.00%}"; /// /// Turns the provided accuracy into a percentage with 2 decimal places. /// /// The accuracy to be formatted /// Whether to show decimal places if equals 100m /// formatted accuracy in percentage public static string FormatAccuracy(this decimal accuracy, bool alwaysShowDecimals = false) => accuracy == 100 && !alwaysShowDecimals ? "100%" : $"{accuracy:0.00}%"; } }