Java 类sun.misc.FloatingDecimal 实例源码

项目:jdk8u-jdk    文件:TestFloatingDecimal.java   
private static int testAppendToDouble() {
    System.out.println("  testAppendToDouble");
    int failures = 0;

    for(int i = 0; i < NUM_RANDOM_TESTS; i++) {
        double[] d = new double[] {
            RANDOM.nextLong(),
            RANDOM.nextGaussian(),
            RANDOM.nextDouble()*Double.MAX_VALUE
        };
        for(int j = 0; j < d.length; j++) {
            OldFloatingDecimalForTest ofd = new OldFloatingDecimalForTest(d[j]);
            StringBuilder sb = new StringBuilder();
            ofd.appendTo(sb);
            String oldString = sb.toString();
            sb = new StringBuilder();
            FloatingDecimal.appendTo(d[j], sb);
            String newString = sb.toString();
            failures += check("testAppendToDouble", oldString, newString);
        }
    }

    return failures;
}
项目:jdk8u-jdk    文件:TestFloatingDecimal.java   
private static int testAppendToFloat() {
    System.out.println("  testAppendToFloat");
    int failures = 0;

    for(int i = 0; i < NUM_RANDOM_TESTS; i++) {
        float[] f = new float[] {
            RANDOM.nextLong(),
            (float)RANDOM.nextGaussian(),
            RANDOM.nextFloat()*Float.MAX_VALUE
        };
        for(int j = 0; j < f.length; j++) {
            OldFloatingDecimalForTest ofd = new OldFloatingDecimalForTest(f[j]);
            StringBuilder sb = new StringBuilder();
            ofd.appendTo(sb);
            String oldString = sb.toString();
            sb = new StringBuilder();
            FloatingDecimal.appendTo(f[j], sb);
            String newString = sb.toString();
            failures += check("testAppendToFloat", oldString, newString);
        }
    }

    return failures;
}
项目:jdk8u-jdk    文件:TestFloatingDecimal.java   
private static int testParseDouble() {
    System.out.println("  testParseDouble");
    int failures = 0;

    for(int i = 0; i < NUM_RANDOM_TESTS; i++) {
        double[] d = new double[] {
            RANDOM.nextLong(),
            RANDOM.nextGaussian(),
            RANDOM.nextDouble()*Double.MAX_VALUE
        };
        for(int j = 0; j < d.length; j++) {
            OldFloatingDecimalForTest ofd = new OldFloatingDecimalForTest(d[j]);
            String javaFormatString = ofd.toJavaFormatString();
            ofd = OldFloatingDecimalForTest.readJavaFormatString(javaFormatString);
            double oldDouble = ofd.doubleValue();
            double newDouble = FloatingDecimal.parseDouble(javaFormatString);
            failures += check("testParseDouble", oldDouble, newDouble);
        }
    }

    return failures;
}
项目:jdk8u-jdk    文件:TestFloatingDecimal.java   
private static int testParseFloat() {
    System.out.println("  testParseFloat");
    int failures = 0;

    for(int i = 0; i < NUM_RANDOM_TESTS; i++) {
        float[] f = new float[] {
            RANDOM.nextInt(),
            (float)RANDOM.nextGaussian(),
            RANDOM.nextFloat()*Float.MAX_VALUE
        };
        for(int j = 0; j < f.length; j++) {
            OldFloatingDecimalForTest ofd = new OldFloatingDecimalForTest(f[j]);
            String javaFormatString = ofd.toJavaFormatString();
            ofd = OldFloatingDecimalForTest.readJavaFormatString(javaFormatString);
            float oldFloat = ofd.floatValue();
            float newFloat = FloatingDecimal.parseFloat(javaFormatString);
            failures += check("testParseFloat", oldFloat, newFloat);
        }
    }

    return failures;
}
项目:jdk8u-jdk    文件:TestFloatingDecimal.java   
private static int testToJavaFormatStringDoubleFixed() {
    System.out.println("    testToJavaFormatStringDoubleFixed");
    int failures = 0;

    double[] d = new double [] {
        -5.9522650387500933e18, // dtoa() fast path
        0.872989018674569,      // dtoa() fast iterative - long
        1.1317400099603851e308  // dtoa() slow iterative
    };

    for(int i = 0; i < d.length; i++) {
        OldFloatingDecimalForTest ofd = new OldFloatingDecimalForTest(d[i]);
        failures += check("testToJavaFormatStringDoubleFixed", ofd.toJavaFormatString(), FloatingDecimal.toJavaFormatString(d[i]));
    }

    return failures;
}
项目:jdk8u-jdk    文件:TestFloatingDecimal.java   
private static int testToJavaFormatStringDoubleRandom() {
    System.out.println("    testToJavaFormatStringDoubleRandom");
    int failures = 0;

    for(int i = 0; i < NUM_RANDOM_TESTS; i++) {
        double[] d = new double[] {
            RANDOM.nextLong(),
            RANDOM.nextGaussian(),
            RANDOM.nextDouble()*Double.MAX_VALUE
        };
        for(int j = 0; j < d.length; j++) {
            OldFloatingDecimalForTest ofd = new OldFloatingDecimalForTest(d[j]);
            failures += check("testToJavaFormatStringDoubleRandom", ofd.toJavaFormatString(), FloatingDecimal.toJavaFormatString(d[j]));
        }
    }

    return failures;
}
项目:jdk8u-jdk    文件:TestFloatingDecimal.java   
private static int testToJavaFormatStringFloatFixed() {
    System.out.println("    testToJavaFormatStringFloatFixed");
    int failures = 0;

    float[] f = new float[] {
        -9.8784166e8f, // dtoa() fast path
        0.70443946f,   // dtoa() fast iterative - int
        1.8254228e37f  // dtoa() slow iterative
    };

    for(int i = 0; i < f.length; i++) {
        OldFloatingDecimalForTest ofd = new OldFloatingDecimalForTest(f[i]);
        failures += check("testToJavaFormatStringFloatFixed", ofd.toJavaFormatString(), FloatingDecimal.toJavaFormatString(f[i]));
    }

    return failures;
}
项目:jdk8u-jdk    文件:TestFloatingDecimal.java   
private static int testToJavaFormatStringFloatRandom() {
    System.out.println("    testToJavaFormatStringFloatRandom");
    int failures = 0;

    for(int i = 0; i < NUM_RANDOM_TESTS; i++) {
        float[] f = new float[] {
            RANDOM.nextInt(),
            (float)RANDOM.nextGaussian(),
            RANDOM.nextFloat()*Float.MAX_VALUE
        };
        for(int j = 0; j < f.length; j++) {
            OldFloatingDecimalForTest ofd = new OldFloatingDecimalForTest(f[j]);
            failures += check("testToJavaFormatStringFloatRandom", ofd.toJavaFormatString(), FloatingDecimal.toJavaFormatString(f[j]));
        }
    }

    return failures;
}
项目:jdk8u_jdk    文件:TestFloatingDecimal.java   
private static int testAppendToDouble() {
    System.out.println("  testAppendToDouble");
    int failures = 0;

    for(int i = 0; i < NUM_RANDOM_TESTS; i++) {
        double[] d = new double[] {
            RANDOM.nextLong(),
            RANDOM.nextGaussian(),
            RANDOM.nextDouble()*Double.MAX_VALUE
        };
        for(int j = 0; j < d.length; j++) {
            OldFloatingDecimalForTest ofd = new OldFloatingDecimalForTest(d[j]);
            StringBuilder sb = new StringBuilder();
            ofd.appendTo(sb);
            String oldString = sb.toString();
            sb = new StringBuilder();
            FloatingDecimal.appendTo(d[j], sb);
            String newString = sb.toString();
            failures += check("testAppendToDouble", oldString, newString);
        }
    }

    return failures;
}
项目:jdk8u_jdk    文件:TestFloatingDecimal.java   
private static int testAppendToFloat() {
    System.out.println("  testAppendToFloat");
    int failures = 0;

    for(int i = 0; i < NUM_RANDOM_TESTS; i++) {
        float[] f = new float[] {
            RANDOM.nextLong(),
            (float)RANDOM.nextGaussian(),
            RANDOM.nextFloat()*Float.MAX_VALUE
        };
        for(int j = 0; j < f.length; j++) {
            OldFloatingDecimalForTest ofd = new OldFloatingDecimalForTest(f[j]);
            StringBuilder sb = new StringBuilder();
            ofd.appendTo(sb);
            String oldString = sb.toString();
            sb = new StringBuilder();
            FloatingDecimal.appendTo(f[j], sb);
            String newString = sb.toString();
            failures += check("testAppendToFloat", oldString, newString);
        }
    }

    return failures;
}
项目:jdk8u_jdk    文件:TestFloatingDecimal.java   
private static int testParseDouble() {
    System.out.println("  testParseDouble");
    int failures = 0;

    for(int i = 0; i < NUM_RANDOM_TESTS; i++) {
        double[] d = new double[] {
            RANDOM.nextLong(),
            RANDOM.nextGaussian(),
            RANDOM.nextDouble()*Double.MAX_VALUE
        };
        for(int j = 0; j < d.length; j++) {
            OldFloatingDecimalForTest ofd = new OldFloatingDecimalForTest(d[j]);
            String javaFormatString = ofd.toJavaFormatString();
            ofd = OldFloatingDecimalForTest.readJavaFormatString(javaFormatString);
            double oldDouble = ofd.doubleValue();
            double newDouble = FloatingDecimal.parseDouble(javaFormatString);
            failures += check("testParseDouble", oldDouble, newDouble);
        }
    }

    return failures;
}
项目:jdk8u_jdk    文件:TestFloatingDecimal.java   
private static int testParseFloat() {
    System.out.println("  testParseFloat");
    int failures = 0;

    for(int i = 0; i < NUM_RANDOM_TESTS; i++) {
        float[] f = new float[] {
            RANDOM.nextInt(),
            (float)RANDOM.nextGaussian(),
            RANDOM.nextFloat()*Float.MAX_VALUE
        };
        for(int j = 0; j < f.length; j++) {
            OldFloatingDecimalForTest ofd = new OldFloatingDecimalForTest(f[j]);
            String javaFormatString = ofd.toJavaFormatString();
            ofd = OldFloatingDecimalForTest.readJavaFormatString(javaFormatString);
            float oldFloat = ofd.floatValue();
            float newFloat = FloatingDecimal.parseFloat(javaFormatString);
            failures += check("testParseFloat", oldFloat, newFloat);
        }
    }

    return failures;
}
项目:jdk8u_jdk    文件:TestFloatingDecimal.java   
private static int testToJavaFormatStringDoubleFixed() {
    System.out.println("    testToJavaFormatStringDoubleFixed");
    int failures = 0;

    double[] d = new double [] {
        -5.9522650387500933e18, // dtoa() fast path
        0.872989018674569,      // dtoa() fast iterative - long
        1.1317400099603851e308  // dtoa() slow iterative
    };

    for(int i = 0; i < d.length; i++) {
        OldFloatingDecimalForTest ofd = new OldFloatingDecimalForTest(d[i]);
        failures += check("testToJavaFormatStringDoubleFixed", ofd.toJavaFormatString(), FloatingDecimal.toJavaFormatString(d[i]));
    }

    return failures;
}
项目:jdk8u_jdk    文件:TestFloatingDecimal.java   
private static int testToJavaFormatStringDoubleRandom() {
    System.out.println("    testToJavaFormatStringDoubleRandom");
    int failures = 0;

    for(int i = 0; i < NUM_RANDOM_TESTS; i++) {
        double[] d = new double[] {
            RANDOM.nextLong(),
            RANDOM.nextGaussian(),
            RANDOM.nextDouble()*Double.MAX_VALUE
        };
        for(int j = 0; j < d.length; j++) {
            OldFloatingDecimalForTest ofd = new OldFloatingDecimalForTest(d[j]);
            failures += check("testToJavaFormatStringDoubleRandom", ofd.toJavaFormatString(), FloatingDecimal.toJavaFormatString(d[j]));
        }
    }

    return failures;
}
项目:jdk8u_jdk    文件:TestFloatingDecimal.java   
private static int testToJavaFormatStringFloatFixed() {
    System.out.println("    testToJavaFormatStringFloatFixed");
    int failures = 0;

    float[] f = new float[] {
        -9.8784166e8f, // dtoa() fast path
        0.70443946f,   // dtoa() fast iterative - int
        1.8254228e37f  // dtoa() slow iterative
    };

    for(int i = 0; i < f.length; i++) {
        OldFloatingDecimalForTest ofd = new OldFloatingDecimalForTest(f[i]);
        failures += check("testToJavaFormatStringFloatFixed", ofd.toJavaFormatString(), FloatingDecimal.toJavaFormatString(f[i]));
    }

    return failures;
}
项目:jdk8u_jdk    文件:TestFloatingDecimal.java   
private static int testToJavaFormatStringFloatRandom() {
    System.out.println("    testToJavaFormatStringFloatRandom");
    int failures = 0;

    for(int i = 0; i < NUM_RANDOM_TESTS; i++) {
        float[] f = new float[] {
            RANDOM.nextInt(),
            (float)RANDOM.nextGaussian(),
            RANDOM.nextFloat()*Float.MAX_VALUE
        };
        for(int j = 0; j < f.length; j++) {
            OldFloatingDecimalForTest ofd = new OldFloatingDecimalForTest(f[j]);
            failures += check("testToJavaFormatStringFloatRandom", ofd.toJavaFormatString(), FloatingDecimal.toJavaFormatString(f[j]));
        }
    }

    return failures;
}
项目:lookaside_java-1.8.0-openjdk    文件:TestFloatingDecimal.java   
private static int testAppendToDouble() {
    System.out.println("  testAppendToDouble");
    int failures = 0;

    for(int i = 0; i < NUM_RANDOM_TESTS; i++) {
        double[] d = new double[] {
            RANDOM.nextLong(),
            RANDOM.nextGaussian(),
            RANDOM.nextDouble()*Double.MAX_VALUE
        };
        for(int j = 0; j < d.length; j++) {
            OldFloatingDecimalForTest ofd = new OldFloatingDecimalForTest(d[j]);
            StringBuilder sb = new StringBuilder();
            ofd.appendTo(sb);
            String oldString = sb.toString();
            sb = new StringBuilder();
            FloatingDecimal.appendTo(d[j], sb);
            String newString = sb.toString();
            failures += check("testAppendToDouble", oldString, newString);
        }
    }

    return failures;
}
项目:lookaside_java-1.8.0-openjdk    文件:TestFloatingDecimal.java   
private static int testAppendToFloat() {
    System.out.println("  testAppendToFloat");
    int failures = 0;

    for(int i = 0; i < NUM_RANDOM_TESTS; i++) {
        float[] f = new float[] {
            RANDOM.nextLong(),
            (float)RANDOM.nextGaussian(),
            RANDOM.nextFloat()*Float.MAX_VALUE
        };
        for(int j = 0; j < f.length; j++) {
            OldFloatingDecimalForTest ofd = new OldFloatingDecimalForTest(f[j]);
            StringBuilder sb = new StringBuilder();
            ofd.appendTo(sb);
            String oldString = sb.toString();
            sb = new StringBuilder();
            FloatingDecimal.appendTo(f[j], sb);
            String newString = sb.toString();
            failures += check("testAppendToFloat", oldString, newString);
        }
    }

    return failures;
}
项目:lookaside_java-1.8.0-openjdk    文件:TestFloatingDecimal.java   
private static int testParseDouble() {
    System.out.println("  testParseDouble");
    int failures = 0;

    for(int i = 0; i < NUM_RANDOM_TESTS; i++) {
        double[] d = new double[] {
            RANDOM.nextLong(),
            RANDOM.nextGaussian(),
            RANDOM.nextDouble()*Double.MAX_VALUE
        };
        for(int j = 0; j < d.length; j++) {
            OldFloatingDecimalForTest ofd = new OldFloatingDecimalForTest(d[j]);
            String javaFormatString = ofd.toJavaFormatString();
            ofd = OldFloatingDecimalForTest.readJavaFormatString(javaFormatString);
            double oldDouble = ofd.doubleValue();
            double newDouble = FloatingDecimal.parseDouble(javaFormatString);
            failures += check("testParseDouble", oldDouble, newDouble);
        }
    }

    return failures;
}
项目:lookaside_java-1.8.0-openjdk    文件:TestFloatingDecimal.java   
private static int testParseFloat() {
    System.out.println("  testParseFloat");
    int failures = 0;

    for(int i = 0; i < NUM_RANDOM_TESTS; i++) {
        float[] f = new float[] {
            RANDOM.nextInt(),
            (float)RANDOM.nextGaussian(),
            RANDOM.nextFloat()*Float.MAX_VALUE
        };
        for(int j = 0; j < f.length; j++) {
            OldFloatingDecimalForTest ofd = new OldFloatingDecimalForTest(f[j]);
            String javaFormatString = ofd.toJavaFormatString();
            ofd = OldFloatingDecimalForTest.readJavaFormatString(javaFormatString);
            float oldFloat = ofd.floatValue();
            float newFloat = FloatingDecimal.parseFloat(javaFormatString);
            failures += check("testParseFloat", oldFloat, newFloat);
        }
    }

    return failures;
}
项目:lookaside_java-1.8.0-openjdk    文件:TestFloatingDecimal.java   
private static int testToJavaFormatStringDoubleFixed() {
    System.out.println("    testToJavaFormatStringDoubleFixed");
    int failures = 0;

    double[] d = new double [] {
        -5.9522650387500933e18, // dtoa() fast path
        0.872989018674569,      // dtoa() fast iterative - long
        1.1317400099603851e308  // dtoa() slow iterative
    };

    for(int i = 0; i < d.length; i++) {
        OldFloatingDecimalForTest ofd = new OldFloatingDecimalForTest(d[i]);
        failures += check("testToJavaFormatStringDoubleFixed", ofd.toJavaFormatString(), FloatingDecimal.toJavaFormatString(d[i]));
    }

    return failures;
}
项目:lookaside_java-1.8.0-openjdk    文件:TestFloatingDecimal.java   
private static int testToJavaFormatStringDoubleRandom() {
    System.out.println("    testToJavaFormatStringDoubleRandom");
    int failures = 0;

    for(int i = 0; i < NUM_RANDOM_TESTS; i++) {
        double[] d = new double[] {
            RANDOM.nextLong(),
            RANDOM.nextGaussian(),
            RANDOM.nextDouble()*Double.MAX_VALUE
        };
        for(int j = 0; j < d.length; j++) {
            OldFloatingDecimalForTest ofd = new OldFloatingDecimalForTest(d[j]);
            failures += check("testToJavaFormatStringDoubleRandom", ofd.toJavaFormatString(), FloatingDecimal.toJavaFormatString(d[j]));
        }
    }

    return failures;
}
项目:lookaside_java-1.8.0-openjdk    文件:TestFloatingDecimal.java   
private static int testToJavaFormatStringFloatFixed() {
    System.out.println("    testToJavaFormatStringFloatFixed");
    int failures = 0;

    float[] f = new float[] {
        -9.8784166e8f, // dtoa() fast path
        0.70443946f,   // dtoa() fast iterative - int
        1.8254228e37f  // dtoa() slow iterative
    };

    for(int i = 0; i < f.length; i++) {
        OldFloatingDecimalForTest ofd = new OldFloatingDecimalForTest(f[i]);
        failures += check("testToJavaFormatStringFloatFixed", ofd.toJavaFormatString(), FloatingDecimal.toJavaFormatString(f[i]));
    }

    return failures;
}
项目:lookaside_java-1.8.0-openjdk    文件:TestFloatingDecimal.java   
private static int testToJavaFormatStringFloatRandom() {
    System.out.println("    testToJavaFormatStringFloatRandom");
    int failures = 0;

    for(int i = 0; i < NUM_RANDOM_TESTS; i++) {
        float[] f = new float[] {
            RANDOM.nextInt(),
            (float)RANDOM.nextGaussian(),
            RANDOM.nextFloat()*Float.MAX_VALUE
        };
        for(int j = 0; j < f.length; j++) {
            OldFloatingDecimalForTest ofd = new OldFloatingDecimalForTest(f[j]);
            failures += check("testToJavaFormatStringFloatRandom", ofd.toJavaFormatString(), FloatingDecimal.toJavaFormatString(f[j]));
        }
    }

    return failures;
}
项目:warp10-platform    文件:GTSEncoder.java   
/**
 * Encode the given GTS instance, converting doubles to BigDecimal to get a chance to
 * store them more efficiently
 * 
 * @param gts
 */
public synchronized void encodeOptimized(GeoTimeSerie gts) throws IOException {
  StringBuilder sb = new StringBuilder();

  char[] chars = null;

  for (int i = 0; i < gts.values; i++) {
    Object value = GTSHelper.valueAtIndex(gts, i);

    if ((value instanceof Double) && Double.isFinite((double) value)) {
      sb.setLength(0);
      BinaryToASCIIConverter btoa = FloatingDecimal.getBinaryToASCIIConverter((double) value);
      btoa.appendTo(sb);
      if (null == chars || chars.length < sb.length()) {
        chars = new char[sb.length()];
      }

      sb.getChars(0, sb.length(), chars, 0);

      value = new BigDecimal(chars, 0, sb.length());
    }
    addValue(gts.ticks[i], null != gts.locations ? gts.locations[i] : GeoTimeSerie.NO_LOCATION, null != gts.elevations ? gts.elevations[i] : GeoTimeSerie.NO_ELEVATION, value);
  }
}
项目:infobip-open-jdk-8    文件:TestFloatingDecimal.java   
private static int testAppendToDouble() {
    System.out.println("  testAppendToDouble");
    int failures = 0;

    for(int i = 0; i < NUM_RANDOM_TESTS; i++) {
        double[] d = new double[] {
            RANDOM.nextLong(),
            RANDOM.nextGaussian(),
            RANDOM.nextDouble()*Double.MAX_VALUE
        };
        for(int j = 0; j < d.length; j++) {
            OldFloatingDecimalForTest ofd = new OldFloatingDecimalForTest(d[j]);
            StringBuilder sb = new StringBuilder();
            ofd.appendTo(sb);
            String oldString = sb.toString();
            sb = new StringBuilder();
            FloatingDecimal.appendTo(d[j], sb);
            String newString = sb.toString();
            failures += check("testAppendToDouble", oldString, newString);
        }
    }

    return failures;
}
项目:infobip-open-jdk-8    文件:TestFloatingDecimal.java   
private static int testAppendToFloat() {
    System.out.println("  testAppendToFloat");
    int failures = 0;

    for(int i = 0; i < NUM_RANDOM_TESTS; i++) {
        float[] f = new float[] {
            RANDOM.nextLong(),
            (float)RANDOM.nextGaussian(),
            RANDOM.nextFloat()*Float.MAX_VALUE
        };
        for(int j = 0; j < f.length; j++) {
            OldFloatingDecimalForTest ofd = new OldFloatingDecimalForTest(f[j]);
            StringBuilder sb = new StringBuilder();
            ofd.appendTo(sb);
            String oldString = sb.toString();
            sb = new StringBuilder();
            FloatingDecimal.appendTo(f[j], sb);
            String newString = sb.toString();
            failures += check("testAppendToFloat", oldString, newString);
        }
    }

    return failures;
}
项目:infobip-open-jdk-8    文件:TestFloatingDecimal.java   
private static int testParseDouble() {
    System.out.println("  testParseDouble");
    int failures = 0;

    for(int i = 0; i < NUM_RANDOM_TESTS; i++) {
        double[] d = new double[] {
            RANDOM.nextLong(),
            RANDOM.nextGaussian(),
            RANDOM.nextDouble()*Double.MAX_VALUE
        };
        for(int j = 0; j < d.length; j++) {
            OldFloatingDecimalForTest ofd = new OldFloatingDecimalForTest(d[j]);
            String javaFormatString = ofd.toJavaFormatString();
            ofd = OldFloatingDecimalForTest.readJavaFormatString(javaFormatString);
            double oldDouble = ofd.doubleValue();
            double newDouble = FloatingDecimal.parseDouble(javaFormatString);
            failures += check("testParseDouble", oldDouble, newDouble);
        }
    }

    return failures;
}
项目:infobip-open-jdk-8    文件:TestFloatingDecimal.java   
private static int testParseFloat() {
    System.out.println("  testParseFloat");
    int failures = 0;

    for(int i = 0; i < NUM_RANDOM_TESTS; i++) {
        float[] f = new float[] {
            RANDOM.nextInt(),
            (float)RANDOM.nextGaussian(),
            RANDOM.nextFloat()*Float.MAX_VALUE
        };
        for(int j = 0; j < f.length; j++) {
            OldFloatingDecimalForTest ofd = new OldFloatingDecimalForTest(f[j]);
            String javaFormatString = ofd.toJavaFormatString();
            ofd = OldFloatingDecimalForTest.readJavaFormatString(javaFormatString);
            float oldFloat = ofd.floatValue();
            float newFloat = FloatingDecimal.parseFloat(javaFormatString);
            failures += check("testParseFloat", oldFloat, newFloat);
        }
    }

    return failures;
}
项目:infobip-open-jdk-8    文件:TestFloatingDecimal.java   
private static int testToJavaFormatStringDoubleFixed() {
    System.out.println("    testToJavaFormatStringDoubleFixed");
    int failures = 0;

    double[] d = new double [] {
        -5.9522650387500933e18, // dtoa() fast path
        0.872989018674569,      // dtoa() fast iterative - long
        1.1317400099603851e308  // dtoa() slow iterative
    };

    for(int i = 0; i < d.length; i++) {
        OldFloatingDecimalForTest ofd = new OldFloatingDecimalForTest(d[i]);
        failures += check("testToJavaFormatStringDoubleFixed", ofd.toJavaFormatString(), FloatingDecimal.toJavaFormatString(d[i]));
    }

    return failures;
}
项目:infobip-open-jdk-8    文件:TestFloatingDecimal.java   
private static int testToJavaFormatStringDoubleRandom() {
    System.out.println("    testToJavaFormatStringDoubleRandom");
    int failures = 0;

    for(int i = 0; i < NUM_RANDOM_TESTS; i++) {
        double[] d = new double[] {
            RANDOM.nextLong(),
            RANDOM.nextGaussian(),
            RANDOM.nextDouble()*Double.MAX_VALUE
        };
        for(int j = 0; j < d.length; j++) {
            OldFloatingDecimalForTest ofd = new OldFloatingDecimalForTest(d[j]);
            failures += check("testToJavaFormatStringDoubleRandom", ofd.toJavaFormatString(), FloatingDecimal.toJavaFormatString(d[j]));
        }
    }

    return failures;
}
项目:infobip-open-jdk-8    文件:TestFloatingDecimal.java   
private static int testToJavaFormatStringFloatFixed() {
    System.out.println("    testToJavaFormatStringFloatFixed");
    int failures = 0;

    float[] f = new float[] {
        -9.8784166e8f, // dtoa() fast path
        0.70443946f,   // dtoa() fast iterative - int
        1.8254228e37f  // dtoa() slow iterative
    };

    for(int i = 0; i < f.length; i++) {
        OldFloatingDecimalForTest ofd = new OldFloatingDecimalForTest(f[i]);
        failures += check("testToJavaFormatStringFloatFixed", ofd.toJavaFormatString(), FloatingDecimal.toJavaFormatString(f[i]));
    }

    return failures;
}
项目:infobip-open-jdk-8    文件:TestFloatingDecimal.java   
private static int testToJavaFormatStringFloatRandom() {
    System.out.println("    testToJavaFormatStringFloatRandom");
    int failures = 0;

    for(int i = 0; i < NUM_RANDOM_TESTS; i++) {
        float[] f = new float[] {
            RANDOM.nextInt(),
            (float)RANDOM.nextGaussian(),
            RANDOM.nextFloat()*Float.MAX_VALUE
        };
        for(int j = 0; j < f.length; j++) {
            OldFloatingDecimalForTest ofd = new OldFloatingDecimalForTest(f[j]);
            failures += check("testToJavaFormatStringFloatRandom", ofd.toJavaFormatString(), FloatingDecimal.toJavaFormatString(f[j]));
        }
    }

    return failures;
}
项目:jdk8u-dev-jdk    文件:TestFloatingDecimal.java   
private static int testAppendToDouble() {
    System.out.println("  testAppendToDouble");
    int failures = 0;

    for(int i = 0; i < NUM_RANDOM_TESTS; i++) {
        double[] d = new double[] {
            RANDOM.nextLong(),
            RANDOM.nextGaussian(),
            RANDOM.nextDouble()*Double.MAX_VALUE
        };
        for(int j = 0; j < d.length; j++) {
            OldFloatingDecimalForTest ofd = new OldFloatingDecimalForTest(d[j]);
            StringBuilder sb = new StringBuilder();
            ofd.appendTo(sb);
            String oldString = sb.toString();
            sb = new StringBuilder();
            FloatingDecimal.appendTo(d[j], sb);
            String newString = sb.toString();
            failures += check("testAppendToDouble", oldString, newString);
        }
    }

    return failures;
}
项目:jdk8u-dev-jdk    文件:TestFloatingDecimal.java   
private static int testAppendToFloat() {
    System.out.println("  testAppendToFloat");
    int failures = 0;

    for(int i = 0; i < NUM_RANDOM_TESTS; i++) {
        float[] f = new float[] {
            RANDOM.nextLong(),
            (float)RANDOM.nextGaussian(),
            RANDOM.nextFloat()*Float.MAX_VALUE
        };
        for(int j = 0; j < f.length; j++) {
            OldFloatingDecimalForTest ofd = new OldFloatingDecimalForTest(f[j]);
            StringBuilder sb = new StringBuilder();
            ofd.appendTo(sb);
            String oldString = sb.toString();
            sb = new StringBuilder();
            FloatingDecimal.appendTo(f[j], sb);
            String newString = sb.toString();
            failures += check("testAppendToFloat", oldString, newString);
        }
    }

    return failures;
}
项目:jdk8u-dev-jdk    文件:TestFloatingDecimal.java   
private static int testParseDouble() {
    System.out.println("  testParseDouble");
    int failures = 0;

    for(int i = 0; i < NUM_RANDOM_TESTS; i++) {
        double[] d = new double[] {
            RANDOM.nextLong(),
            RANDOM.nextGaussian(),
            RANDOM.nextDouble()*Double.MAX_VALUE
        };
        for(int j = 0; j < d.length; j++) {
            OldFloatingDecimalForTest ofd = new OldFloatingDecimalForTest(d[j]);
            String javaFormatString = ofd.toJavaFormatString();
            ofd = OldFloatingDecimalForTest.readJavaFormatString(javaFormatString);
            double oldDouble = ofd.doubleValue();
            double newDouble = FloatingDecimal.parseDouble(javaFormatString);
            failures += check("testParseDouble", oldDouble, newDouble);
        }
    }

    return failures;
}
项目:jdk8u-dev-jdk    文件:TestFloatingDecimal.java   
private static int testParseFloat() {
    System.out.println("  testParseFloat");
    int failures = 0;

    for(int i = 0; i < NUM_RANDOM_TESTS; i++) {
        float[] f = new float[] {
            RANDOM.nextInt(),
            (float)RANDOM.nextGaussian(),
            RANDOM.nextFloat()*Float.MAX_VALUE
        };
        for(int j = 0; j < f.length; j++) {
            OldFloatingDecimalForTest ofd = new OldFloatingDecimalForTest(f[j]);
            String javaFormatString = ofd.toJavaFormatString();
            ofd = OldFloatingDecimalForTest.readJavaFormatString(javaFormatString);
            float oldFloat = ofd.floatValue();
            float newFloat = FloatingDecimal.parseFloat(javaFormatString);
            failures += check("testParseFloat", oldFloat, newFloat);
        }
    }

    return failures;
}
项目:jdk8u-dev-jdk    文件:TestFloatingDecimal.java   
private static int testToJavaFormatStringDoubleFixed() {
    System.out.println("    testToJavaFormatStringDoubleFixed");
    int failures = 0;

    double[] d = new double [] {
        -5.9522650387500933e18, // dtoa() fast path
        0.872989018674569,      // dtoa() fast iterative - long
        1.1317400099603851e308  // dtoa() slow iterative
    };

    for(int i = 0; i < d.length; i++) {
        OldFloatingDecimalForTest ofd = new OldFloatingDecimalForTest(d[i]);
        failures += check("testToJavaFormatStringDoubleFixed", ofd.toJavaFormatString(), FloatingDecimal.toJavaFormatString(d[i]));
    }

    return failures;
}
项目:jdk8u-dev-jdk    文件:TestFloatingDecimal.java   
private static int testToJavaFormatStringDoubleRandom() {
    System.out.println("    testToJavaFormatStringDoubleRandom");
    int failures = 0;

    for(int i = 0; i < NUM_RANDOM_TESTS; i++) {
        double[] d = new double[] {
            RANDOM.nextLong(),
            RANDOM.nextGaussian(),
            RANDOM.nextDouble()*Double.MAX_VALUE
        };
        for(int j = 0; j < d.length; j++) {
            OldFloatingDecimalForTest ofd = new OldFloatingDecimalForTest(d[j]);
            failures += check("testToJavaFormatStringDoubleRandom", ofd.toJavaFormatString(), FloatingDecimal.toJavaFormatString(d[j]));
        }
    }

    return failures;
}
项目:jdk8u-dev-jdk    文件:TestFloatingDecimal.java   
private static int testToJavaFormatStringFloatFixed() {
    System.out.println("    testToJavaFormatStringFloatFixed");
    int failures = 0;

    float[] f = new float[] {
        -9.8784166e8f, // dtoa() fast path
        0.70443946f,   // dtoa() fast iterative - int
        1.8254228e37f  // dtoa() slow iterative
    };

    for(int i = 0; i < f.length; i++) {
        OldFloatingDecimalForTest ofd = new OldFloatingDecimalForTest(f[i]);
        failures += check("testToJavaFormatStringFloatFixed", ofd.toJavaFormatString(), FloatingDecimal.toJavaFormatString(f[i]));
    }

    return failures;
}