本文整理了Java中java.lang.Number.floatValue()
方法的一些代码示例,展示了Number.floatValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Number.floatValue()
方法的具体详情如下:
包路径:java.lang.Number
类名称:Number
方法名:floatValue
[英]Returns this object's value as a float. Might involve rounding.
[中]以浮点形式返回此对象的值。可能需要四舍五入。
代码示例来源:origin: apache/incubator-dubbo
@Override
public Object decode(Object jv) {
if (jv instanceof Number) {
return ((Number) jv).floatValue();
}
return (float) 0;
}
};
代码示例来源:origin: apache/incubator-dubbo
@Override
public Object decode(Object jv) {
if (jv instanceof Number) {
return ((Number) jv).floatValue();
}
return (float) 0;
}
};
代码示例来源:origin: alibaba/druid
public static Float castToFloat(Object val) {
if (val == null || val == EVAL_VALUE_NULL) {
return null;
}
if (val instanceof Float) {
return (Float) val;
}
return ((Number) val).floatValue();
}
代码示例来源:origin: apache/incubator-dubbo
/**
* get float value.
*
* @param index index.
* @param def default value.
* @return value or default value.
*/
public float getFloat(int index, float def) {
Object tmp = mArray.get(index);
return tmp != null && tmp instanceof Number ? ((Number) tmp).floatValue() : def;
}
代码示例来源:origin: apache/incubator-dubbo
@Override
public Object decode(Object jv) {
if (jv instanceof Number) {
return new Float(((Number) jv).floatValue());
}
return (Float) null;
}
};
代码示例来源:origin: apache/incubator-dubbo
/**
* get float value.
*
* @param key key.
* @param def default value.
* @return value or default value.
*/
public float getFloat(String key, float def) {
Object tmp = mMap.get(key);
return tmp != null && tmp instanceof Number ? ((Number) tmp).floatValue() : def;
}
代码示例来源:origin: apache/incubator-dubbo
/**
* get float value.
*
* @param index index.
* @param def default value.
* @return value or default value.
*/
public float getFloat(int index, float def) {
Object tmp = mArray.get(index);
return tmp != null && tmp instanceof Number ? ((Number) tmp).floatValue() : def;
}
代码示例来源:origin: apache/incubator-dubbo
/**
* get float value.
*
* @param key key.
* @param def default value.
* @return value or default value.
*/
public float getFloat(String key, float def) {
Object tmp = mMap.get(key);
return tmp != null && tmp instanceof Number ? ((Number) tmp).floatValue() : def;
}
代码示例来源:origin: apache/incubator-dubbo
@Override
public Object decode(Object jv) {
if (jv instanceof Number) {
return new Float(((Number) jv).floatValue());
}
return (Float) null;
}
};
代码示例来源:origin: apache/incubator-dubbo
@Override
public void encode(Object obj, JSONWriter jb) throws IOException {
jb.valueFloat(((Number) obj).floatValue());
}
};
代码示例来源:origin: apache/incubator-dubbo
@Override
public void encode(Object obj, JSONWriter jb) throws IOException {
jb.valueFloat(((Number) obj).floatValue());
}
};
代码示例来源:origin: alibaba/druid
@Override
public float getFloat(int columnIndex) throws SQLException {
Number number = (Number) getObject(columnIndex);
if (number == null) {
return 0;
}
return number.floatValue();
}
代码示例来源:origin: alibaba/druid
@Override
public float getFloat(int columnIndex) throws SQLException {
Number number = (Number) getObject(columnIndex);
if (number == null) {
return 0;
}
return number.floatValue();
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public Float convert(String source) {
try {
NumberFormat nf = NumberFormat.getInstance(Locale.GERMAN);
return nf.parse(source).floatValue();
}
catch (ParseException ex) {
throw new IllegalArgumentException(ex);
}
}
});
代码示例来源:origin: alibaba/druid
@Override
public void setNumber(Number number) {
if (number == null) {
this.setValue(null);
return;
}
this.setValue(number.floatValue());
}
代码示例来源:origin: alibaba/druid
@Override
public void setNumber(Number number) {
if (number == null) {
this.setValue(null);
return;
}
this.setValue(number.floatValue());
}
代码示例来源:origin: apache/incubator-dubbo
public float getParameter(String key, float defaultValue) {
Number n = getNumbers().get(key);
if (n != null) {
return n.floatValue();
}
String value = getParameter(key);
if (StringUtils.isEmpty(value)) {
return defaultValue;
}
float f = Float.parseFloat(value);
getNumbers().put(key, f);
return f;
}
代码示例来源:origin: apache/incubator-dubbo
public float getParameter(String key, float defaultValue) {
Number n = getNumbers().get(key);
if (n != null) {
return n.floatValue();
}
String value = getParameter(key);
if (StringUtils.isEmpty(value)) {
return defaultValue;
}
float f = Float.parseFloat(value);
getNumbers().put(key, f);
return f;
}
代码示例来源:origin: apache/incubator-dubbo
public float getMethodParameter(String method, String key, float defaultValue) {
String methodKey = method + "." + key;
Number n = getNumbers().get(methodKey);
if (n != null) {
return n.floatValue();
}
String value = getMethodParameter(method, key);
if (StringUtils.isEmpty(value)) {
return defaultValue;
}
float f = Float.parseFloat(value);
getNumbers().put(methodKey, f);
return f;
}
代码示例来源:origin: apache/incubator-dubbo
public float getMethodParameter(String method, String key, float defaultValue) {
String methodKey = method + "." + key;
Number n = getNumbers().get(methodKey);
if (n != null) {
return n.floatValue();
}
String value = getMethodParameter(method, key);
if (StringUtils.isEmpty(value)) {
return defaultValue;
}
float f = Float.parseFloat(value);
getNumbers().put(methodKey, f);
return f;
}
内容来源于网络,如有侵权,请联系作者删除!