2
I have the following method:
private static String encode(long number){
StringBuilder builder = new StringBuilder();
number = number < 0 ? ~(number << 1) : number << 1;
while (number >= 0x20) {
builder.append(Character.toChars((int) ((0x20 | (number & 0x1f)) + 63)));
number >>= 5;
}
builder.append(Character.toChars((int) (number + 63)));
return builder.toString();
}
I would like help to try to understand the following parts:
number = number < 0 ? ~ (number << 1) number << 1;
((0x20 | (number & 0x1f)) + 63)
If I’m not mistaken you already have the answer to this here on the site. The problem is that the search does not recognize characters like
<
(which is why I edited)– Jéf Bueno
I found this question after editing @jbueno http://stackoverflow.com/questions/1050989/double-greater-than-sign-in-java
– user28595
Related: How the bit offset in C/C works++?
– Jéf Bueno
@bigown just ask the javascript utility is exact like in java?
– user28595
@diegofm exactly. No language I know makes any different. It would practically say that arithmetic operations are different depending on the language.
– Maniero
@jbueno I think it would fit as duplicate too, it is a pity that the mechanism does not allow to choose more than one except when two people do it, which obviously does not happen when a moderator closes.
– Maniero
@bigown I have 1 more question, If you can help me ! O
**~**
do what? Thank you very much!]– Thiago Luiz Domacoski
I was going to vote as a duplicate, actually, but when I came back it was already marked @bigown
– Jéf Bueno
@Thiagoluizdomacoski Open another question. This has already been closed.
– Jéf Bueno
@ThiagoLuizDomacoski http://answall.com/q/1559/101
– Maniero