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 testZeroes() {
    assertEquals(FPOrdering.ordinalOf(0D), 0x8000000000000000L);
    assertEquals(FPOrdering.ordinalOf(0F), 0x80000000L);
    assertEquals(FPOrdering.ordinalOf(-0D), 0x8000000000000000L);
    assertEquals(FPOrdering.ordinalOf(-0F), 0x80000000L);
    assertTrue(Long.compareUnsigned(FPOrdering.ordinalOf(0D),
        FPOrdering.ordinalOf(-1D)) > 0);
    assertTrue(Long.compareUnsigned(FPOrdering.ordinalOf(0F),
        FPOrdering.ordinalOf(-1F)) > 0);
    assertTrue(Long.compareUnsigned(FPOrdering.ordinalOf(0D),
        FPOrdering.ordinalOf(-1e-200D)) > 0);
    assertTrue(Long.compareUnsigned(FPOrdering.ordinalOf(0F),
        FPOrdering.ordinalOf(-1e-20F)) > 0);
  }