• Post Reply Bookmark Topic Watch Topic
  • New Topic

What does this operator do ?  RSS feed

 
Miles Williams
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok.
So I am reading the Oracle Certified Associate Java SE7 Programmer Study Guide and there is an exercise question with an operator I am not familiar with.
It simply asks what would be the output from :



I ran the code and the output is 2.
What IS this >>> operator?
Only time I have ever seen it before is in Python, where it's called a chevron and it's nothing more than the prompt in interactive mode.
Is it something to do with bitwise operations? I only say that because taking 16 in binary 00010000 and shifting 3 times to the right gives you 00000010 which is 2...
Funny thing is that it wasn't mentioned in the text of the chapter that has the question apart from being shown in a table where it states it is "Right shift and Zero fill" with "Left Associativity" . I have no idea what that means. I am guessing left associativity means that the value to the left of the operator is the one we are working on. The right shift (if this IS what I'm guessing it to be - a bitwise operation) means the bits are being shifted to the right. But what is the Zero fill??
Or am I totally off the mark here and it means nothing like I am assuming and it was just a co-incidence that shifting 16 in binary 3 bits to the right results in 2??
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66306
152
IntelliJ IDE Java jQuery Mac Mac OS X
 
Miles Williams
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So my guess was right?
Well fancy that hey.
I tried to google it before asking here but it wouldn't recognize the >>> and just omitted it from what I typing in the search text field.
Thanks Bear.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66306
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had the advantage of knowing what it was to look for.
 
Paul Clapham
Sheriff
Posts: 22828
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, I can see how >>> doesn't work as a Google search term. I would have googled "java operator" (knowing, as you did, that it was a Java operator) and hoped for a link to a page all about Java operators including that one.
 
Miles Williams
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually. I googled ">>> java operator" and it just took it as "java operator" and after searching through a few pages of results I came here.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Miles Williams wrote:Actually. I googled ">>> java operator" and it just took it as "java operator" and after searching through a few pages of results I came here.

I think (but I'm not absolutely certain) that it's also peculiar to Java - or at least was when the language came out - I don't remember it in C or C++ (but I could be wrong; Alzheimers ), possibly because they have unsigned variants of all numeric primitives.

It's actually a very useful operator.

Winston
 
Campbell Ritchie
Marshal
Posts: 56541
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a lot about bitwise operators in this recent thread.
 
Sresh Rangi
Ranch Hand
Posts: 54
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To search for these symbols, you can use SymbolHound.


SymbolHound is a search engine that doesn't ignore special characters. This means you can easily search for symbols like &, %, and π. We hope SymbolHound will help programmers find information about their chosen languages and frameworks more easily.
 
Campbell Ritchie
Marshal
Posts: 56541
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SymbolHound worked nicely, and didn't find any use of >>> in C/C++. Thank you for the information; I had never heard of it before.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!