• 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
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Right bit Shift Operator In Java

 
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to reverse engineer some PHP. This PHP code does a right bit shift operator on a string variable.

All the right bit shifts I have seen are for integers. Can I perform a right bit shift operator on a String in Java?

 
Rancher
Posts: 4686
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

James Ellis wrote:I am trying to reverse engineer some PHP. This PHP code does a right bit shift operator on a string variable.
All the right bit shifts I have seen are for integers. Can I perform a right bit shift operator on a String in Java?



I can't imagine what shift on a String variable would make any sense or have any value.

Do you perhaps mean a byte or char variable containing characters?

Java String variables are Unicode, shifting the whole data array a few bits would make a real mess.
 
James Ellis
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It seems I don't need to do this anyway...i misinterpreted the PHP code.

The PHP code does the following:

$bucket=((crc32($key)>>16)&0x7fff) % $this->bucketcount;

...and I thought that crc32 was returning a string...it turns out its returning a number.

Now if I could only find a java CRC32 class that returned a number that matches the results of the PHP crc32 function...

Would you happen to know any java CRC32 classes?
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you try searching? When I did the one in the JDK was the first hit.
 
You showed up just in time for the waffles! And this 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