zoukankan      html  css  js  c++  java
  • C#double转化成字符串 保留小数位数, 不以科学计数法的形式出现。

    http://www.cnblogs.com/wifi/articles/4075915.html

    double temp=3.1415926; (F)Fixed point:string str1=temp.toString("f1");//保留一位小数 四舍五入 结果:3.1 (F)Fixed point:string str2=temp.toString("f2");//保留两位小数,四舍五入 下面一次类推 结果:3.14 (N)Number:string str2=temp.toString("N");//保留 结果:3.14 (G)General (default):string str2=temp.toString("G");//保留 结果:3.1415926 (P)Percent:string str2=temp.toString("P");//保留 结果:314.16% (E)Scientific:string str2=temp.toString("E");//保留 结果E:3.141593E+000 (C)Currency:string str2=temp.toString("C");//保留 结果:¥3.14 对于double temp=0.000000926的情况,上述方法都不管用,可以通过转成decimal格式再显示。如下所示: string str = ((decimal)temp).toString();
  • 相关阅读:
    Vue 04
    Vue小练习 03
    Vue 03
    Vue小练习 02
    Vue 02
    Vue 小练习01
    Vue 01
    Django 11
    JUC(一):volatile关键字
    Kubernetes【K8S】(五):Service
  • 原文地址:https://www.cnblogs.com/LuoEast/p/6806766.html
Copyright © 2011-2022 走看看