andreachild commented on code in PR #3117:
URL: https://github.com/apache/tinkerpop/pull/3117#discussion_r2080050494
##########
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) {
+ throw exception;
+ }
+ numberInfo.bits <<= 1;
Review Comment:
Would this result in the following type promotions?
* Long -> BigInteger
* Double -> BigDecimal
From previous discussions we had thought to avoid auto promotion to
BigInteger or BigDecimal as those types are 'extended' types and GLVs do not
necessarily support them.
https://tinkerpop.apache.org/docs/3.7.2/dev/io/#_extended
--
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]