本文整理了Java中java.lang.Number.doubleValue()
方法的一些代码示例,展示了Number.doubleValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Number.doubleValue()
方法的具体详情如下:
包路径:java.lang.Number
类名称:Number
方法名:doubleValue
[英]Returns this object's value as a double. Might involve rounding.
[中]以双精度形式返回此对象的值。可能需要四舍五入。
代码示例来源:origin: apache/incubator-dubbo
@Override
public Object decode(Object jv) {
if (jv instanceof Number) {
return ((Number) jv).doubleValue();
}
return (double) 0;
}
};
代码示例来源:origin: apache/incubator-dubbo
@Override
public Object decode(Object jv) {
if (jv instanceof Number) {
return ((Number) jv).doubleValue();
}
return (double) 0;
}
};
代码示例来源:origin: apache/incubator-dubbo
@Override
public Object decode(Object jv) throws IOException {
if (jv instanceof Number) {
return BigDecimal.valueOf(((Number) jv).doubleValue());
}
return (BigDecimal) null;
}
};
代码示例来源:origin: apache/incubator-dubbo
/**
* get double value.
*
* @param key key.
* @param def default value.
* @return value or default value.
*/
public double getDouble(String key, double def) {
Object tmp = mMap.get(key);
return tmp != null && tmp instanceof Number ? ((Number) tmp).doubleValue() : def;
}
代码示例来源:origin: apache/incubator-dubbo
/**
* get double value.
*
* @param index index.
* @param def default value.
* @return value or default value.
*/
public double getDouble(int index, double def) {
Object tmp = mArray.get(index);
return tmp != null && tmp instanceof Number ? ((Number) tmp).doubleValue() : def;
}
代码示例来源:origin: apache/incubator-dubbo
/**
* get double value.
*
* @param key key.
* @param def default value.
* @return value or default value.
*/
public double getDouble(String key, double def) {
Object tmp = mMap.get(key);
return tmp != null && tmp instanceof Number ? ((Number) tmp).doubleValue() : def;
}
代码示例来源:origin: apache/incubator-dubbo
@Override
public Object decode(Object jv) {
if (jv instanceof Number) {
return new Double(((Number) jv).doubleValue());
}
return (Double) null;
}
};
代码示例来源:origin: apache/incubator-dubbo
/**
* get double value.
*
* @param index index.
* @param def default value.
* @return value or default value.
*/
public double getDouble(int index, double def) {
Object tmp = mArray.get(index);
return tmp != null && tmp instanceof Number ? ((Number) tmp).doubleValue() : def;
}
代码示例来源:origin: apache/incubator-dubbo
@Override
public Object decode(Object jv) {
if (jv instanceof Number) {
return new Double(((Number) jv).doubleValue());
}
return (Double) null;
}
};
代码示例来源:origin: apache/incubator-dubbo
@Override
public Object decode(Object jv) throws IOException {
if (jv instanceof Number) {
return BigDecimal.valueOf(((Number) jv).doubleValue());
}
return (BigDecimal) null;
}
};
代码示例来源:origin: google/guava
/**
* Adds the given values to the dataset.
*
* @param values a series of values, which will be converted to {@code double} values (this may
* cause loss of precision)
*/
public void addAll(Iterator<? extends Number> values) {
while (values.hasNext()) {
add(values.next().doubleValue());
}
}
代码示例来源:origin: google/guava
@Override
public Double transformEntry(Number key, Number value) {
return key.doubleValue() + value.doubleValue();
}
};
代码示例来源:origin: google/guava
/**
* Adds the given values to the dataset.
*
* @param values a series of values, which will be converted to {@code double} values (this may
* cause loss of precision)
*/
public void addAll(Iterable<? extends Number> values) {
for (Number value : values) {
add(value.doubleValue());
}
}
代码示例来源:origin: apache/incubator-dubbo
@Override
public void encode(Object obj, JSONWriter jb) throws IOException {
jb.valueDouble(((Number) obj).doubleValue());
}
};
代码示例来源:origin: apache/incubator-dubbo
@Override
public void encode(Object obj, JSONWriter jb) throws IOException {
jb.valueDouble(((Number) obj).doubleValue());
}
};
代码示例来源:origin: stackoverflow.com
DecimalFormat df = new DecimalFormat("#.####");
df.setRoundingMode(RoundingMode.CEILING);
for (Number n : Arrays.asList(12, 123.12345, 0.23, 0.1, 2341234.212431324)) {
Double d = n.doubleValue();
System.out.println(df.format(d));
}
代码示例来源:origin: google/guava
@Override
public int compare(Number a, Number b) {
return ((Double) a.doubleValue()).compareTo(b.doubleValue());
}
代码示例来源:origin: apache/incubator-dubbo
public double getParameter(String key, double defaultValue) {
Number n = getNumbers().get(key);
if (n != null) {
return n.doubleValue();
}
String value = getParameter(key);
if (StringUtils.isEmpty(value)) {
return defaultValue;
}
double d = Double.parseDouble(value);
getNumbers().put(key, d);
return d;
}
代码示例来源:origin: apache/incubator-dubbo
public double getParameter(String key, double defaultValue) {
Number n = getNumbers().get(key);
if (n != null) {
return n.doubleValue();
}
String value = getParameter(key);
if (StringUtils.isEmpty(value)) {
return defaultValue;
}
double d = Double.parseDouble(value);
getNumbers().put(key, d);
return d;
}
代码示例来源:origin: apache/incubator-dubbo
public double getMethodParameter(String method, String key, double defaultValue) {
String methodKey = method + "." + key;
Number n = getNumbers().get(methodKey);
if (n != null) {
return n.doubleValue();
}
String value = getMethodParameter(method, key);
if (StringUtils.isEmpty(value)) {
return defaultValue;
}
double d = Double.parseDouble(value);
getNumbers().put(methodKey, d);
return d;
}
内容来源于网络,如有侵权,请联系作者删除!