Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Regarding Bit Shifting

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

Can anybody please provide me some URL's related to bit shifting operation?
I mean containing examples related to bit shifting etc.

Thanks
Sneha
 
Ranch Hand
Posts: 274
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Shena,

check the following GREAT links:
http://www.javaranch.com/journal/200406/ScjpTipLine-BitShifting.html
http://www.javaranch.com/campfire/StoryBits.jsp

Plus read the following as well:

Shift and Bitwise operators are used to manipulate data at bit level.

Shift operatorsBitwise operators
>>&
<<^
>>>|
~

Shift operators should be used only with operands of type int or long, though they can also be used with other integral types. Shift operators always return a result of type INT or LONG.

Positive integer0..0 110012
Negative integer1..1 1100-4

Negative integer1..1 1100-4
Signed right-shift1..1 1110-2
unsigned right-shift0..1 11102147483646
Left-shift1..1 1000-8

With the unsigned right-shift operator (>>> and the left shift operator, the new bits are always set to 0.

The result of ~x will always be the value ((-x) -1)




regards,
Gitesh
[ August 31, 2007: Message edited by: Gitesh Ramchandani ]
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic