// Range checks
constructWithError("1e"+Integer.MIN_VALUE);
constructWithError("10e"+Integer.MIN_VALUE);
constructWithError("0.01e"+Integer.MIN_VALUE);
constructWithError("1e"+((long)Integer.MIN_VALUE-1));
leadingExponentZeroTest();
nonAsciiZeroTest();
/* These BigDecimals produce a string with an exponent > Integer.MAX_VALUE */
roundtripWithAbnormalExponent(BigDecimal.valueOf(10, Integer.MIN_VALUE));
roundtripWithAbnormalExponent(BigDecimal.valueOf(Long.MIN_VALUE, Integer.MIN_VALUE));
roundtripWithAbnormalExponent(new BigDecimal(new BigInteger("1" + "0".repeat(100)), Integer.MIN_VALUE));
/* These Strings have an exponent > Integer.MAX_VALUE */
roundtripWithAbnormalExponent("1.0E+2147483649");
roundtripWithAbnormalExponent("-9.223372036854775808E+2147483666");
roundtripWithAbnormalExponent("1.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E+2147483748");
// Roundtrip tests
Random random = RandomFactory.getRandom(); for (int i=0; i<100; i++) { int size = random.nextInt(100) + 1;
BigInteger bi = new BigInteger(size, random); if (random.nextBoolean())
bi = bi.negate(); int decimalLength = bi.toString().length(); int scale = random.nextInt(decimalLength);
BigDecimal bd = new BigDecimal(bi, scale);
String bdString = bd.toString(); // System.err.println("bi" + bi.toString() + "\tscale " + scale); // System.err.println("bd string: " + bdString);
BigDecimal bdDoppel = new BigDecimal(bdString); if (!bd.equals(bdDoppel)) {
System.err.println("bd string: scale: " + bd.scale() + "\t" + bdString);
System.err.println("bd doppel: scale: " + bdDoppel.scale() + "\t" + bdDoppel.toString()); thrownew RuntimeException("String constructor failure.");
}
}
}
// Test with more excess zeros than the largest number of // decimal digits needed to represent a long int limit = ((int)Math.log10(Long.MAX_VALUE)) + 6; for(int i = 0; i < limit; i++, middle += "0") {
String t1 = start + middle;
String t2 = t1 + end;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.