How can I translate the following code to objective c? (Value is an int)
while (value != 0) {
value >>>= 1;
And is there a general replacement for the >>> operator?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The operation is not directly supported, so you need to use a mask. Depending on the size of your
valuevariable, you need to pick a mask of a different size.If
valueisshort, use0x7FFF; ifvalueislong long, use0x7FFFFFFFFFFFFF.Alternatively, you can declare
valueas unsigned: then the regular shift-assign would not sign-extend thevalue. In fact, big part of the reason the>>>operator was added to Java is the absence of unsigned types in the language.