Solved

what is this mean ">>"?

Posted on 2006-11-14
8
201 Views
Last Modified: 2011-09-20
i have this code from my old colleague, can anyone tell me what does this means?

 
abyLic[4] = (byte) (iLicenseID);
        abyLic[5] = (byte) (iLicenseID >> 8);
        abyLic[6] = (byte) (iLicenseID >> 16);
        abyLic[7] = (byte) (iLicenseID >> 24);
       
        abyLic[8] = (byte) (iSMSCounter);
        abyLic[9] = (byte) (iSMSCounter >> 8);


the abyLic[] is an array and the iLicenseID is int.

what doest that mean by iLicenseId >> 8 ??
is that he is trying to set the value to 8 in abyLic[5]?
0
Comment
Question by:taiping
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
Shift right operator

0
 
LVL 23

Expert Comment

by:Ajay-Singh
Comment Utility
bitwise shift
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 92

Expert Comment

by:objects
Comment Utility
0
 
LVL 35

Accepted Solution

by:
girionis earned 125 total points
Comment Utility
Just to fill up with what the other experts suggested

>what doest that mean by iLicenseId >> 8 ??

The ">>" is a binary operator and it means "right shift the value in the "iLicensedId" eight times". The value of "iLicencedId" is an integer. When you right shift a value you make it smaller. For example if the "iLicencedId" holds the value of 512, which in *binary* it is 000100000000, and you right shift 8 times, it becomes 000000000010 (=2 in decimal). As you see you can see the digit 1 is moved 8 positions to the right. This is what the >> operator is doing, it moves the digits to the right.

> is that he is trying to set the value to 8 in abyLic[5]?

No, he is setting the *converted* value (the one that was shifted to the right 8 times), i.e. the result of the right-shift operation, to the 6th position os the "abyLic" array
0
 
LVL 35

Expert Comment

by:girionis
Comment Utility
Sorry the 512 binary should be 001000000000.
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
taiping - why did you ignore previous correct answers?
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now