Java Bit Flip flip(long a)

Here you can find the source of flip(long a)

Description

A (self-inverse) bijection which converts the ordering on unsigned longs to the ordering on longs, that is, a <= b as unsigned longs if and only if flip(a) <= flip(b) as signed longs.

License

Apache License

Declaration

private static long flip(long a) 

Method Source Code

//package com.java2s;
//Licensed under the Apache License, Version 2.0 (the "License");

public class Main {
    private static int flip(int value) {
        return value ^ Integer.MIN_VALUE;
    }/*from   w  ww . j av  a 2s  . co  m*/

    /**
     * A (self-inverse) bijection which converts the ordering on unsigned longs to the ordering on longs, that is,
     * {@code a <= b} as unsigned longs if and only if {@code flip(a) <= flip(b)} as signed longs.
     */
    private static long flip(long a) {
        return a ^ Long.MIN_VALUE;
    }
}

Related

  1. flip(int i)
  2. flip(int value)
  3. flipBitAsBinaryString(int flipBit)
  4. flipBitAt(int bitIndex, byte b)
  5. flipBits(byte[] bytes, int start, int bitLength)
  6. flipBits(int n)