public void testDoubles() throws Exception {
  double[] values=new double[]{Double.NEGATIVE_INFINITY,-2.3E25,-1.0E15,-1.0,-1.0E-1,-1.0E-2,-0.0,+0.0,1.0E-2,1.0E-1,1.0,1.0E15,2.3E25,Double.POSITIVE_INFINITY,Double.NaN};
  long[] encoded=new long[values.length];
  for (int i=0; i < values.length; i++) {
    encoded[i]=NumericUtils.doubleToSortableLong(values[i]);
    assertTrue("forward and back conversion should generate same double",Double.compare(values[i],NumericUtils.sortableLongToDouble(encoded[i])) == 0);
  }
  for (int i=1; i < encoded.length; i++) {
    assertTrue("check sort order",encoded[i - 1] < encoded[i]);
  }
}

public void testDoubles ( ) throws Exception { double [ ] values = new double [ ] { Double . NEGATIVE_INFINITY , - 2.3E25 , - 1.0E15 , - 1.0 , - 1.0E-1 , - 1.0E-2 , - 0.0 , + 0.0 , 1.0E-2 , 1.0E-1 , 1.0 , 1.0E15 , 2.3E25 , Double . POSITIVE_INFINITY , Double . NaN } ; long [ ] encoded = new long [ values . length ] ; for ( int i = 0 ; i < values . length ; i ++ ) { encoded [ i ] = NumericUtils . doubleToSortableLong ( values [ i ] ) ; assertTrue ( "forward and back conversion should generate same double" , Double . compare ( values [ i ] , NumericUtils . sortableLongToDouble ( encoded [ i ] ) ) == 0 ) ; } for ( int i = 1 ; i < encoded . length ; i ++ ) { assertTrue ( "check sort order" , encoded [ i - 1 ] < encoded [ i ] ) ; } }
check various sorted values of doubles ( including extreme values ) check for correct ordering of the encoded bytes and that values round - trip .
