On Wed, 6 Apr 2022 18:22:45 GMT, John R Rose <jr...@openjdk.org> wrote:

>> Paul Sandoz has updated the pull request incrementally with two additional 
>> commits since the last revision:
>> 
>>  - Fix typo.
>>  - Provide examples.
>
> src/java.base/share/classes/java/lang/Integer.java line 1781:
> 
>> 1779:      * All the upper remaining bits of the compressed value are set
>> 1780:      * to zero.
>> 1781:      *
> 
> Following Alan's comment, I suggest the following examples:
> 
> 
>   compress(0x9ABCDEF, 0x0F0F0FF) == 0xACEF
>   compress(x, 1<<n) == (x>>n & 1)
>   compress(x, -1<<n) == x >>> n
>   compress(m, m) == (m==-1||m==0)? m : (1<<bitCount(m))-1
>   compress(x, m) == compress(x & m, m)
>   compress(expand(x, m), m) == x & compress(m, m)
>   (compress(x, m) >>> n) & 1 == /*the bit of x corresponding to the nth set 
> bit in m*/
> 
> 
> …In two places.  Similarly, examples for expand:
> 
> 
>   expand(0x9ABCDEF, 0x0F0F0FF) == 0xC0D0EF
>   expand(x, 1<<n) == (x&1) << n
>   expand(x, -1<<n) == x << n
>   expand(-1, m) == m
>   expand(x, m) == expand(x, m) & m
>   expand(compress(x, m), m) == x & m
>   expand(1<<n, m) == /*the nth set bit in m, as a mask in place; cf. 
> highest/lowestOneBit*/
> 
> 
> (Please double check these examples!)

Examples added in latest commit.

-------------

PR: https://git.openjdk.java.net/jdk/pull/8115

Reply via email to