如何点后double转换成2号?转换成、double

由网友(Hypoxia.(缺氧))分享简介:可能重复: Round小数点后双至2显著图如何到小数点后转换为双数2?例如:双X = 123.45678;我需要 X = 123.45 (在Java对于Android)在此先感谢解决方案 X = Math.floor(X * 100)/ 100;Possible Duplicate:Round a double...

可能重复:   Round小数点后双至2显著图

如何到小数点后转换为双数2?

例如:

 双X = 123.45678;
 

我需要 X = 123.45 (在Java对于Android)

在此先感谢

解决方案

  X = Math.floor(X * 100)/ 100;
 
2.4 double和float的使用和转化

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;

阅读全文

相关推荐

最新文章