xuzifu666 commented on code in PR #4180:
URL: https://github.com/apache/calcite/pull/4180#discussion_r1944608186
##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -369,6 +369,23 @@ public static String hex(String value) {
return Hex.encodeHexString(value.getBytes(UTF_8));
}
+ /** SQL BIN(long) function. */
+ public static String bin(long value) {
+ int zeros = Long.numberOfLeadingZeros(value);
+ if (zeros == Long.SIZE) {
+ return "0";
+ } else {
+ int length = Long.SIZE - zeros;
+ byte[] bytes = new byte[length];
+ for (int index = length - 1; index >= 0; index--) {
+ bytes[index] = (byte) ((value & 0x1) == 1 ? '1' : '0');
Review Comment:
Here stand for & with hex 1,if lowerest is 1 return 1,otherwise return 0.
--
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]