Topic: 请教(怎样保留两位小数?)

  Print this page

1.请教(怎样保留两位小数?) Copy to clipboard
Posted by: ykx_binghua
Posted on: 2005-08-07 16:58

请使用准确的文字描述作为标题
Your next post without a proper Subject will be removed.


怎样保留两位小数???

2.Re:请教(怎样保留两位小数?) [Re: ykx_binghua] Copy to clipboard
Posted by: why
Posted on: 2005-08-07 19:15

import java.text.DecimalFormat;

double d = 123.45678;
DecimalFormat f = new DecimalFormat("0.00");
String s = f.format(d);

double d2 = ((int) Math.round(d * 100.0)) / 100.0;

3.Re:请教(怎样保留两位小数?) [Re: ykx_binghua] Copy to clipboard
Posted by: ykx_binghua
Posted on: 2005-08-09 18:39

谢谢元老!


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923