@@ -3779,7 +3779,7 @@ private static ByteString binaryOperator(
37793779 * @param y the shift amount (positive: left shift, negative: right shift)
37803780 * @return the shifted integer
37813781 */
3782- public static int leftShift (int x , int y ) {
3782+ public static int leftShift (int x , long y ) {
37833783 int shift = Math .floorMod (y , 32 ); // normalize to 0~31
37843784 return y >= 0 ? x << shift : x >> shift ; // arithmetic right shift
37853785 }
@@ -3793,23 +3793,11 @@ public static int leftShift(int x, int y) {
37933793 * @param y the shift amount
37943794 * @return the shifted long value
37953795 */
3796- public static long leftShift (long x , int y ) {
3796+ public static long leftShift (long x , long y ) {
37973797 int shift = Math .floorMod (y , 64 ); // normalize to 0~63
37983798 return y >= 0 ? x << shift : x >> shift ;
37993799 }
38003800
3801- /**
3802- * Performs PostgresSQL-style bitwise shift on an int value with a long shift amount.
3803- *
3804- * @param x the int value to shift
3805- * @param y the long shift amount
3806- * @return the shifted value as long
3807- */
3808- public static long leftShift (int x , long y ) {
3809- int shift = Math .floorMod (y , 32 ); // normalize to 0~31
3810- return y >= 0 ? (long ) x << shift : (long ) x >> shift ;
3811- }
3812-
38133801 /**
38143802 * Performs PostgresSQL-style bitwise shift on a byte array.
38153803 * Positive shift: left shift.
@@ -3819,7 +3807,7 @@ public static long leftShift(int x, long y) {
38193807 * @param y the shift amount in bits
38203808 * @return the shifted byte array
38213809 */
3822- public static byte [] leftShift (byte [] bytes , int y ) {
3810+ public static byte [] leftShift (byte [] bytes , long y ) {
38233811 if (bytes .length == 0 ) {
38243812 return new byte [0 ];
38253813 }
@@ -3866,15 +3854,15 @@ public static byte[] leftShift(byte[] bytes, int y) {
38663854 * @param y the shift amount in bits
38673855 * @return shifted ByteString
38683856 */
3869- public static ByteString leftShift (ByteString bytes , int y ) {
3857+ public static ByteString leftShift (ByteString bytes , long y ) {
38703858 return new ByteString (leftShift (bytes .getBytes (), y ));
38713859 }
38723860
38733861 /**
38743862 * Performs PostgresSQL-style bitwise shift on UByte.
38753863 * Overflow bits are masked to 8 bits.
38763864 */
3877- public static UByte leftShift (UByte x , int y ) {
3865+ public static UByte leftShift (UByte x , long y ) {
38783866 int shift = Math .floorMod (y , 8 );
38793867 int val = x .byteValue () & 0xFF ;
38803868 val = (y >= 0 ) ? (val << shift ) & 0xFF : (val >> shift ) & 0xFF ;
@@ -3885,7 +3873,7 @@ public static UByte leftShift(UByte x, int y) {
38853873 * Performs PostgresSQL-style bitwise shift on UShort.
38863874 * Overflow bits are masked to 16 bits.
38873875 */
3888- public static UShort leftShift (UShort x , int y ) {
3876+ public static UShort leftShift (UShort x , long y ) {
38893877 int shift = Math .floorMod (y , 16 );
38903878 int val = x .shortValue () & 0xFFFF ;
38913879 val = (y >= 0 ) ? (val << shift ) & 0xFFFF : (val >> shift ) & 0xFFFF ;
@@ -3896,7 +3884,7 @@ public static UShort leftShift(UShort x, int y) {
38963884 * Performs PostgresSQL-style bitwise shift on UInteger.
38973885 * Overflow bits are masked to 32 bits.
38983886 */
3899- public static UInteger leftShift (UInteger x , int y ) {
3887+ public static UInteger leftShift (UInteger x , long y ) {
39003888 int shift = Math .floorMod (y , 32 );
39013889 long val = x .longValue () & 0xFFFFFFFFL ;
39023890 val = (y >= 0 ) ? (val << shift ) & 0xFFFFFFFFL : (val >> shift ) & 0xFFFFFFFFL ;
@@ -3907,7 +3895,7 @@ public static UInteger leftShift(UInteger x, int y) {
39073895 * Performs PostgresSQL-style bitwise shift on ULong.
39083896 * Overflow bits are masked to 64 bits (long shifts naturally truncate).
39093897 */
3910- public static ULong leftShift (ULong x , int y ) {
3898+ public static ULong leftShift (ULong x , long y ) {
39113899 int shift = Math .floorMod (y , 64 );
39123900 long val = x .longValue ();
39133901 val = (y >= 0 ) ? val << shift : val >> shift ;
@@ -3921,7 +3909,7 @@ public static ULong leftShift(ULong x, int y) {
39213909 * @param y the shift amount (positive: right shift, negative: left shift)
39223910 * @return the shifted integer
39233911 */
3924- public static int rightShift (int x , int y ) {
3912+ public static int rightShift (int x , long y ) {
39253913 int shift = Math .floorMod (y , 32 ); // normalize to 0~31
39263914 return y >= 0 ? x >> shift : x << shift ; // arithmetic right shift
39273915 }
@@ -3935,23 +3923,11 @@ public static int rightShift(int x, int y) {
39353923 * @param y the shift amount
39363924 * @return the shifted long value
39373925 */
3938- public static long rightShift (long x , int y ) {
3926+ public static long rightShift (long x , long y ) {
39393927 int shift = Math .floorMod (y , 64 ); // normalize to 0~63
39403928 return y >= 0 ? x >> shift : x << shift ;
39413929 }
39423930
3943- /**
3944- * Performs PostgresSQL-style bitwise shift on an int value with a long shift amount.
3945- *
3946- * @param x the int value to shift
3947- * @param y the long shift amount
3948- * @return the shifted value as long
3949- */
3950- public static long rightShift (int x , long y ) {
3951- int shift = Math .floorMod (y , 32 ); // normalize to 0~31
3952- return y >= 0 ? (long ) x >> shift : (long ) x << shift ;
3953- }
3954-
39553931 /**
39563932 * Performs PostgresSQL-style bitwise shift on a byte array.
39573933 * Positive shift: right shift.
@@ -3961,7 +3937,7 @@ public static long rightShift(int x, long y) {
39613937 * @param y the shift amount in bits
39623938 * @return the shifted byte array
39633939 */
3964- public static byte [] rightShift (byte [] bytes , int y ) {
3940+ public static byte [] rightShift (byte [] bytes , long y ) {
39653941 if (bytes .length == 0 ) {
39663942 return new byte [0 ];
39673943 }
@@ -4008,15 +3984,15 @@ public static byte[] rightShift(byte[] bytes, int y) {
40083984 * @param y the shift amount in bits
40093985 * @return shifted ByteString
40103986 */
4011- public static ByteString rightShift (ByteString bytes , int y ) {
3987+ public static ByteString rightShift (ByteString bytes , long y ) {
40123988 return new ByteString (rightShift (bytes .getBytes (), y ));
40133989 }
40143990
40153991 /**
40163992 * Performs PostgresSQL-style bitwise shift on UByte.
40173993 * Overflow bits are masked to 8 bits.
40183994 */
4019- public static UByte rightShift (UByte x , int y ) {
3995+ public static UByte rightShift (UByte x , long y ) {
40203996 int shift = Math .floorMod (y , 8 );
40213997 int val = x .byteValue () & 0xFF ;
40223998 val = (y >= 0 ) ? (val >> shift ) & 0xFF : (val << shift ) & 0xFF ;
@@ -4027,7 +4003,7 @@ public static UByte rightShift(UByte x, int y) {
40274003 * Performs PostgresSQL-style bitwise shift on UShort.
40284004 * Overflow bits are masked to 16 bits.
40294005 */
4030- public static UShort rightShift (UShort x , int y ) {
4006+ public static UShort rightShift (UShort x , long y ) {
40314007 int shift = Math .floorMod (y , 16 );
40324008 int val = x .shortValue () & 0xFFFF ;
40334009 val = (y >= 0 ) ? (val >> shift ) & 0xFFFF : (val << shift ) & 0xFFFF ;
@@ -4038,7 +4014,7 @@ public static UShort rightShift(UShort x, int y) {
40384014 * Performs PostgresSQL-style bitwise shift on UInteger.
40394015 * Overflow bits are masked to 32 bits.
40404016 */
4041- public static UInteger rightShift (UInteger x , int y ) {
4017+ public static UInteger rightShift (UInteger x , long y ) {
40424018 int shift = Math .floorMod (y , 32 );
40434019 long val = x .longValue () & 0xFFFFFFFFL ;
40444020 val = (y >= 0 ) ? (val >> shift ) & 0xFFFFFFFFL : (val << shift ) & 0xFFFFFFFFL ;
@@ -4049,7 +4025,7 @@ public static UInteger rightShift(UInteger x, int y) {
40494025 * Performs PostgresSQL-style bitwise shift on ULong.
40504026 * Overflow bits are masked to 64 bits (long shifts naturally truncate).
40514027 */
4052- public static ULong rightShift (ULong x , int y ) {
4028+ public static ULong rightShift (ULong x , long y ) {
40534029 int shift = Math .floorMod (y , 64 );
40544030 long val = x .longValue ();
40554031 val = (y >= 0 ) ? val >> shift : val << shift ;
0 commit comments