public static long ordinalOf(double value) {
    if (value == Double.POSITIVE_INFINITY) {
      return 0xFFFFFFFFFFFFFFFFL;
    }
    if (value == Double.NEGATIVE_INFINITY || Double.isNaN(value)) {
      return 0;
    }
    long bits = Double.doubleToLongBits(value);
    // need negatives to come before positives
    if ((bits & Long.MIN_VALUE) == Long.MIN_VALUE) {
      // conflate 0/-0, or reverse order of negatives
      bits = bits == Long.MIN_VALUE ? Long.MIN_VALUE : ~bits;
    } else {
      // positives after negatives
      bits ^= Long.MIN_VALUE;
    }
    return bits;
  }
@Test
  public void testInfinities() {
    assertEquals(FPOrdering.ordinalOf(Double.NEGATIVE_INFINITY), 0);
    assertEquals(FPOrdering.ordinalOf(Float.NEGATIVE_INFINITY), 0);
    assertEquals(FPOrdering.ordinalOf(Double.POSITIVE_INFINITY), 0xFFFFFFFFFFFFFFFFL);
    assertEquals(FPOrdering.ordinalOf(Float.POSITIVE_INFINITY), 0xFFFFFFFFL);
  }