本文整理汇总了Java中sun.misc.FloatingDecimal.parseDouble方法的典型用法代码示例。如果您正苦于以下问题:Java FloatingDecimal.parseDouble方法的具体用法?Java FloatingDecimal.parseDouble怎么用?Java FloatingDecimal.parseDouble使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sun.misc.FloatingDecimal
的用法示例。
在下文中一共展示了FloatingDecimal.parseDouble方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testParseDouble
import sun.misc.FloatingDecimal; //导入方法依赖的package包/类
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;
}
示例2: parseDouble
import sun.misc.FloatingDecimal; //导入方法依赖的package包/类
/**
* Returns a new {@code double} initialized to the value
* represented by the specified {@code String}, as performed
* by the {@code valueOf} method of class
* {@code Double}.
*
* @param s the string to be parsed.
* @return the {@code double} value represented by the string
* argument.
* @throws NullPointerException if the string is null
* @throws NumberFormatException if the string does not contain
* a parsable {@code double}.
* @see java.lang.Double#valueOf(String)
* @since 1.2
*/
public static double parseDouble(String s) throws NumberFormatException {
return FloatingDecimal.parseDouble(s);
}