• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

unsigned right shift operator ">>>".

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ranchers

i am always confuse to solve " unsigned right shift operator ">>>". ".

can anyone explain with examples how it works.

Thanks
 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi srinibash udayasingh ,
If the left-hand operand is positive, the result is the same as a right-hift
For example: 16 >> 2 = 4
Decimal 16 00000000000000000000000000010000
Right-shift 2 00000000000000000000000000010000
fill left 00000000000000000000000000000100
discard right 00000000000000000000000000000100 -> Decimal 4

If the left-hand operand is negative,
For example: -16 >>> 2 = 1,073,741,820
Decimal -16 11111111111111111111111111110000
>>> 2 11111111111111111111111111110000
fill left 0011111111111111111111111111110000
discard right 00111111111111111111111111111100 -> 1,073,741,820.

Hope it will help you.
 
author
Posts: 9050
21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
remember this topic is valid for the 1.4 exam but it's NOT on the 5.0 exam.
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The signed right shift operator (>>) shifts to the right while maintaining the sign. That means it fills in positions on the left with the same value as the "sign bit" (the leftmost bit before the shift). This has the effect of keeping positive values (with a sign bit of 0) positive by filling in with zeros, and keeping negative values (with a sign bit of 1) negative by filling in with ones.

The unsigned right shift operator (>>>) shits to the right without caring what the original sign was. It simply fills in positions on the left with zeros.

(Note Bert's post above.)
[ July 20, 2007: Message edited by: marc weber ]
 
You'll never get away with this you overconfident blob! The most you will ever get is this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic