andreachild commented on code in PR #3117:
URL: https://github.com/apache/tinkerpop/pull/3117#discussion_r2080034022


##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/NumberHelper.java:
##########
@@ -361,8 +377,18 @@ public static Class<? extends Number> 
getHighestCommonNumberClass(final boolean
      */
     public static Number add(final Number a, final Number b) {
         if (null == a || null == b) return a;
-        final Class<? extends Number> clazz = getHighestCommonNumberClass(a, 
b);
-        return getHelper(clazz).add.apply(a, b);
+        NumberInfo numberInfo = getHighestCommonNumberInfo(false, a, b);
+        while (true) {
+            try {
+                final Class<? extends Number> clazz = 
determineNumberClass(numberInfo.bits, numberInfo.fp);
+                return getHelper(clazz).add.apply(a, b);
+            } catch (ArithmeticException exception) {
+                if (numberInfo.bits == 128) {

Review Comment:
   Nit: consider changing the check to `>=128` in case there is a bug 
introduced somewhere in the numberInfo.bits calculation, to avoid potential 
endless loop. 



-- 
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