java - Why aren't these two byte operations equal? -


i have following code:

bytebuffer bb = bytebuffer.allocate(totallength); bb.putshort(3); bb.putshort(0);  bb.putint(3 << 15 + 0); 

i don't understand why putting 2 short values byte buffer isn't same second operation

try bb.putint(3 << 16 + 0) instead:)

you inspect bytebuffer with:

system.out.println(arrays.tostring(bb.array())); 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -