diff --git a/SawCut/FormatHelper.cs b/SawCut/FormatHelper.cs index 3d167cd..ab47589 100644 --- a/SawCut/FormatHelper.cs +++ b/SawCut/FormatHelper.cs @@ -1,4 +1,4 @@ -using System; +using System; namespace SawCut { @@ -11,9 +11,9 @@ namespace SawCut /// Converts a decimal measurement to a mixed fraction string representation. /// /// The decimal value to convert - /// The denominator precision (default 32 for 1/32") + /// The denominator precision (default 16 for 1/16") /// A string in the format "whole-numerator/denominator" - public static string ConvertToMixedFraction(decimal input, int precision = 32) + public static string ConvertToMixedFraction(decimal input, int precision = 16) { // Get the whole number part int wholeNumber = (int)input; @@ -35,6 +35,12 @@ namespace SawCut numerator /= gcd; denominator /= gcd; + // If rounding wiped out the fraction → return whole number only + if (numerator == 0) + { + return wholeNumber.ToString(); + } + return $"{wholeNumber}-{numerator}/{denominator}"; }