在java中将double转换为float [英] Convert double to float in java
问题描述
我正面临与 double
转换为 float
相关的问题。实际上我存储在数据库浮点类型 23423424666767
中,但是当我们从下面的代码 getInfoValueNumeric()
中的数据库获取数据时, code> double type。我们得到的价值是 2.3423424666767E13
表单。
I am facing issue related to convert double
to float
. Actually i store in database float type 23423424666767
,but when we get data from database in below code getInfoValueNumeric()
it's double
type .The value we are getting is 2.3423424666767E13
form.
所以我们如何获得 float
格式数据,如 23423424666767
。
So how we get float
format data like 23423424666767
.
2.3423424666767E13至23423424666767
public void setInfoValueNumeric(java.lang.Double value) {
setValue(4, value);
}
@javax.persistence.Column(name = "InfoValueNumeric", precision = 53)
public java.lang.Double getInfoValueNumeric() {
return (java.lang.Double) getValue(4);
}
阅读更多: http://java91.blogspot.in/2017/01/convert-double-to-float-in-java.html
谢谢
Sitansu
推荐答案
要回答您的查询,请参阅如何将2.3423424666767E13转换为
23423424666767
To answer your query on "How to convert 2.3423424666767E13 to 23423424666767"
您可以使用十进制格式化程序格式化十进制数。
You can use a decimal formatter for formatting decimal numbers.
double d = 2.3423424666767E13;
DecimalFormat decimalFormat = new DecimalFormat("#");
System.out.println(decimalFormat.format(d));
输出:23423424666767
Output : 23423424666767
这篇关于在java中将double转换为float的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!