如何点后double转换成2号? [英] how to convert double to 2 number after the dot?
本文介绍了如何点后double转换成2号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
<一href="http://stackoverflow.com/questions/2808535/round-a-double-to-2-significant-figures-after-decimal-point">Round小数点后双至2显著图
如何到小数点后转换为双数2?
例如:
双X = 123.45678;
我需要 X = 123.45
(在Java对于Android)
在此先感谢
解决方案
X = Math.floor(X * 100)/ 100;
Possible Duplicate:
Round a double to 2 significant figures after decimal point
how to convert double to 2 number after the dot ?
for example:
double x=123.45678;
i need that x=123.45
(in java for android)
thanks in advance
解决方案
x = Math.floor(x * 100) / 100;
这篇关于如何点后double转换成2号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文