[ 
https://issues.apache.org/jira/browse/TINKERPOP-3115?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17956191#comment-17956191
 ] 

ASF GitHub Bot commented on TINKERPOP-3115:
-------------------------------------------

Cole-Greer commented on code in PR #3121:
URL: https://github.com/apache/tinkerpop/pull/3121#discussion_r2127322902


##########
docs/src/upgrade/release-3.8.x.asciidoc:
##########
@@ -30,6 +30,26 @@ complete list of all the modifications that are part of this 
release.
 
 === Upgrading for Users
 
+==== Auto promotion of number types
+
+Previously, operations like sum or sack that involved mathematical 
calculations did not automatically promote the result
+to a larger numeric type (e.g., from int to long) when needed. As a result, 
values could wrap around within their current
+type, leading to unexpected behavior. This issue has now been resolved by 
enabling automatic type promotion for results.
+
+Now, any mathematical operations such as Add, Sub, Mul, and Div will now 
automatically promote to the next numeric type
+if an overflow is detected. For integers, the promotion sequence is: byte → 
short → int → long → overflow exception. For
+floating-point numbers, the sequence is: float → double → infinity.
+
+As a example the following query...
+
+"""
+g.withSack(32767s).inject(1s).sack(sum).sack()
+"""
+
+Before would return a short overflow exception or wrap to -1 depending on 
language, but now returns 32769i.
+
+See https://issues.apache.org/jira/browse/TINKERPOP-3115 for more details.

Review Comment:
   Nit: 
   ```suggestion
   See 
link:https://issues.apache.org/jira/browse/TINKERPOP-3115[TINKERPOP-3115] for 
more details.
   ```





> Better handle overflows with sum()
> ----------------------------------
>
>                 Key: TINKERPOP-3115
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-3115
>             Project: TinkerPop
>          Issue Type: Improvement
>          Components: process
>    Affects Versions: 3.7.2
>            Reporter: Stephen Mallette
>            Priority: Minor
>              Labels: breaking
>
> {{code}}
> gremlin> g.inject([(byte) 126, (byte) 2]).sum(local)
> ==>-128
> {{code}}
> that output seems unexpected. oddly it didn't work that way for the global 
> version of {{sum()}} because the type auto promoted to {{long}} because there 
> was multiplication by the {{bulk}} which was {{long}}. That changed on 
> TINKERPOP-3088 though so now even the global version will work like this. 
> seems like it would be better to promote they type whenever it didn't fit 
> into the space allotted. 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to