Question

I found one method in Long class

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

What is the use of this method?

Was it helpful?

Solution

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.

OTHER TIPS

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.

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top