views:

260

answers:

3

I found one method in Long class

public static long reverse(long i) {..}

What is the use of this method?

+6  A: 

From an DDJ article:

Why would you reverse the order of bits in a 32-bit or 64-bit value? Bit reversal can be useful in a variety of contexts. It's useful in image processing for flipping a black-and-white image to create a mirror image. To flip an image horizontally, the pixels in a row of the image must be placed in reverse order. Fast 64-bit bit reversal can be used in the process of reversing a row of black-and-white pixels. Similarly, 64-bit bit reversal is useful for rotating a black and white image 180 degrees.

Lucero
Ok. Thanks for the clarification Lucero.
DKSRathore
+3  A: 

Apparently bit reversal is used in digital signal processing applications, as in the Fast Fourier Transform. I won't pretend to understand why it works, but perhaps the linked-to page will be clear to you.

Jonathan Feinberg
yes Jonathan. The linked page as well is very useful along with urs.
DKSRathore
+1  A: 

You can use bit reversal to make it easier to work with masking operations.

GrayWizardx