• 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
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

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: 4804
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic