ChristophMajcenAtXxxlutz commented on code in PR #3744:
URL: https://github.com/apache/avro/pull/3744#discussion_r3180105808


##########
lang/csharp/src/apache/main/AvroDecimal.cs:
##########
@@ -1140,20 +1140,14 @@ public int CompareTo(AvroDecimal other)
             var unscaledValueCompare = 
UnscaledValue.CompareTo(other.UnscaledValue);
             var scaleCompare = Scale.CompareTo(other.Scale);
 
-            // if both are the same value, return the value
-            if (unscaledValueCompare == scaleCompare)
-            {
-                return unscaledValueCompare;
-            }
-
             // if the scales are both the same return unscaled value
             if (scaleCompare == 0)
             {
                 return unscaledValueCompare;
             }
 
-            var scaledValue = BigInteger.Divide(UnscaledValue, 
BigInteger.Pow(new BigInteger(10), Scale));
-            var otherScaledValue = BigInteger.Divide(other.UnscaledValue, 
BigInteger.Pow(new BigInteger(10), other.Scale));
+            var scaledValue = (decimal) UnscaledValue / (decimal) Math.Pow(10, 
Scale);

Review Comment:
   That's one thing it did wrong, yes. Additionally when comparing for example 
2.5 vs 2.49 it used to compare the unscaled values (25 vs 249 -> right side 
bigger) and the scales (1 vs 2 -> right side bigger) and if both comparisons 
returned the same value would return it as a result therefore returning that 
2.49 is bigger than 2.5.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to