What is the use of the Long.reverse (long) method?

I found one method in the Long class

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

What will be the use of this method?

+6
java performance long-integer api reverse
source share
3 answers

From DDJ article :

Why would you change the order of the bits in a 32-bit or 64-bit value? A little U-turn can be useful in various contexts. It is useful in image processing flipping a black and white image to create a mirror image. To flip the image horizontally, the pixels in the image line must be placed in reverse order. A fast 64-bit bit reversal can be used in the process of changing a line of black and white pixels. By analogy, a 64-bit bit reversal is useful for rotating a black and white image 180 degrees.

+6
source share

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

+3
source share

You can use bit reversal to simplify masking operations.

+1
source share

All Articles