shangxinli commented on code in PR #1042:
URL: https://github.com/apache/iceberg-cpp/pull/1042#discussion_r4316572304


##########
src/iceberg/util/truncate_util.h:
##########
@@ -82,12 +83,20 @@ class ICEBERG_EXPORT TruncateUtils {
 
   /// \brief Truncate an integer v, either int32_t or int64_t, to v - (v % W).
   ///
-  /// The remainder, v % W, must be positive. For languages where % can 
produce negative
-  /// values, the correct truncate function is: v - (((v % W) + W) % W)
+  /// W must be positive. Since C++ can produce a negative remainder, add W 
only

Review Comment:
   For widths above roughly 2^30 this returns 0 where Java's truncateInt wraps 
and returns -2147483646 (v = 2147483645, W = 2147483646) - the right call given 
Java's own int and long paths disagree there, but worth stating in this doc 
block rather than only in a test comment.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to