js的是 .tofixed(2)
c#取日期
convert.todatetime(dt.rows[i]["jgyxq
"]).tostring("
yyyymmdd
");
1 double dvalue = 95.12345;23int ivalue = 10000;4
string strvalue = "
95.12345";
5string result = "";6
7 result = convert.todouble(dvalue).tostring("
0.00
");//
保留小數點後兩位,結果為95.12
8 result = convert.todouble(ivalue).tostring("
0.00
");//
10000.00
9 result = convert.todouble(strvalue).tostring("
0.00
");//
95.12
1011 result = convert.todouble(dvalue).tostring("
p");//
得到小數點後2位的百分比,自動 加上%號;
12 result = convert.todouble(strvalue).tostring("
f4");//
保留小數點後4位;
13//
要注意的一點是 convert.todouble一定要是這種雙精度的,不然會報錯。
link:
php 兩位小數
num 123.456 print r round num,2 num 123.454 print r round num,2 float round float val int precision round 對浮點數進行四捨五入 num 123.456 print r floor num 100...
保留兩位小數
1.只要求保留n位不四捨5入 float f 0.55555f int i int f 100 f float i 1.0 100 2.保留n位,四捨五入 decimal d decimal.round decimal.parse 0.55555 2 3.保留n位四捨五入 math.round 0....
保留兩位小數
num 10.4567 第一種 利用round 對浮點數進行四捨五入 echo round num,2 第二種 利用sprintf格式化字串 format num sprintf 2f num echo format num 第三種 利用千位分組來格式化數字的函式number format echo...