-
Bug
-
Resolution: Fixed
-
P3
-
19
-
b19
-
b28
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8288583 | 20 | Paul Sandoz | P3 | Resolved | Fixed | b03 |
The samples provided in java doc https://download.java.net/java/early_access/jdk19/docs/api/java.base/java/lang/Long.html#compress(long,long) looks not resulting as it states.
For example :
Consider the simple case of compressing the digits of a hexadecimal value:
// Compressing drink to food
compress(0xCAFEBABE, 0xFF00FFF0) == 0xCABAB
The result is if(Long.compress(0xCAFEBABE, 0xFF00FFF0) == 0xCABAB){}
different.
And same for subsequent samples in case of Long
// Returns 1 if the bit at position n is one
compress(x, 1 << n) == (x >> n & 1)
// Logical shift right
compress(x, -1 << n) == x >>> n
....
But these samples works as stated in case of Integer.
For example :
Consider the simple case of compressing the digits of a hexadecimal value:
// Compressing drink to food
compress(0xCAFEBABE, 0xFF00FFF0) == 0xCABAB
The result is if(Long.compress(0xCAFEBABE, 0xFF00FFF0) == 0xCABAB){}
different.
And same for subsequent samples in case of Long
// Returns 1 if the bit at position n is one
compress(x, 1 << n) == (x >> n & 1)
// Logical shift right
compress(x, -1 << n) == x >>> n
....
But these samples works as stated in case of Integer.
- backported by
-
JDK-8288583 Long::compress/expand samples are not correct
- Resolved
- relates to
-
JDK-8283892 Compress and expand bits
- Resolved