diff --git a/TextImprecision/Program.cs b/TextImprecision/Program.cs index 0b5c7e8..61bb1ae 100644 --- a/TextImprecision/Program.cs +++ b/TextImprecision/Program.cs @@ -52,10 +52,9 @@ namespace TextImprecision { decimalPos1 = i; } - if (strDbl1[i < strDbl1.Length ? i : strDbl1.Length-1] != strDbl3[i < strDbl3.Length ? i : strDbl3.Length - 1]) + if (nonMatchIndex1 == -1 && strDbl1[i < strDbl1.Length ? i : strDbl1.Length-1] != strDbl3[i < strDbl3.Length ? i : strDbl3.Length - 1] ) { nonMatchIndex1 = i; - break; } } @@ -66,10 +65,9 @@ namespace TextImprecision { decimalPos2 = i; } - if (strDbl2[i < strDbl2.Length ? i : strDbl2.Length - 1] != strDbl4[i < strDbl4.Length ? i : strDbl4.Length - 1]) + if (nonMatchIndex2 == -1 && strDbl2[i < strDbl2.Length ? i : strDbl2.Length - 1] != strDbl4[i < strDbl4.Length ? i : strDbl4.Length - 1]) { nonMatchIndex2 = i; - break; } } @@ -78,11 +76,11 @@ namespace TextImprecision { if (decimalPos1 > -1) { - output.Write("{0} dp", nonMatchIndex1 - decimalPos1, strDbl1.Length < strDbl3.Length ? strDbl1.Length : strDbl3.Length); + output.Write("{0} dp", nonMatchIndex1 - decimalPos1 -1, strDbl1.Length < strDbl3.Length ? strDbl1.Length : strDbl3.Length); } else { - output.Write("{0} sf", nonMatchIndex1); + output.Write("{0} sf", decimalPos1); } } @@ -95,11 +93,11 @@ namespace TextImprecision { if (decimalPos2 > -1) { - output.Write("{0} dp", nonMatchIndex2 - decimalPos2, strDbl2.Length < strDbl4.Length ? strDbl2.Length : strDbl4.Length); + output.Write("{0} dp", nonMatchIndex2 - decimalPos2 -1, strDbl2.Length < strDbl4.Length ? strDbl2.Length : strDbl4.Length); } else { - output.Write("{0} sf", nonMatchIndex2); + output.Write("{0} sf", decimalPos2); } }