Is there a way to ensure that 'relevant to human visual display' information, particularly in context of interpolated $".." strings
is preserved?
Use case:
double errors = 1.0 / 25000; // => 0.004
var errorMessage = $"Data had {errors:F2}% errors!";
However, the current output is a bit misleading, as it "reads as" '0%' errors.
Data had 0.00% errors.
What is a simple method in C# to achieve an output such as the following instead? (Naturally, there should be no 100.01%..)
Data had 0.01% errors.
The Math.Round
function is not directly suitable without finagling, as the rounding applies to midpoint values, not to 'at precision'.
Math.Round(errors, 2, MidpointRounding.AwayFromZero) // => 0; desired is 0.01