LuXugang commented on code in PR #12405: URL: https://github.com/apache/lucene/pull/12405#discussion_r1275760334
########## lucene/core/src/java/org/apache/lucene/util/NumericUtils.java: ########## @@ -132,6 +132,52 @@ public static void add(int bytesPerDim, int dim, byte[] a, byte[] b, byte[] resu } } + /** + * Modify in-place the given bytes to the next value of the same length that compares greater than + * the current value. This returns false if, and only if, the value is currently equal to the + * maximum possible value. + */ + public static boolean nextUp(byte[] bytes) { Review Comment: @jpountz `nextup` and `nextdown` seems only work well for int/long double/float case can't pass: ```java public void testNextUpDouble() { for (double i : new double[] {Double.MIN_VALUE, Double.MAX_VALUE}) { byte[] b = new byte[Long.BYTES]; long a = NumericUtils.doubleToSortableLong(i); NumericUtils.longToSortableBytes(a, b, 0); if(i == Double.MIN_VALUE){ assertFalse(NumericUtils.nextDown(b)); }else { assertFalse(NumericUtils.nextUp(b)); } } } ``` Because `Double.MIN_VALUE`, `Double.MAX_VALUE`'s byte values are: [-128, 0, 0, 0, 0, 0, 0, 1] and [-1, -17, -1, -1, -1, -1, -1, -1] -- 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: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org