Github user QiangCai commented on a diff in the pull request: https://github.com/apache/carbondata/pull/1065#discussion_r123148990 --- Diff: core/src/main/java/org/apache/carbondata/core/util/ByteUtil.java --- @@ -465,6 +465,39 @@ public static short toShort(byte[] bytes, int offset, final int length) { } /** + * int => byte[3] + * supported range is [-8388607, 8388607], note that Math.pow(2, 24) == 8388608 + */ + public static byte[] to3Bytes(int val) { + assert val <= Math.pow(2, 23) && val >= (-Math.pow(2, 23) - 1); + + int value = val < 0 ? -val : val; + byte[] b = new byte[3]; + b[0] = (byte) (value & 0xFF); + b[1] = (byte) ((value >>> 8) & 0xFF); + b[2] = (byte) ((value >>> 16) & 0x7F); --- End diff -- I think we can do as following. no need to judge minus. b[0] = (byte)(x >> 16) b[1] = (byte)(x >> 8) b[2] = (byte)(x)
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---