zoukankan      html  css  js  c++  java
  • 过虑数字类型后面的0

    //Author:quietwalk

    //Date:2011-06-13

    //Operation:过滤数字型数据的后面的0,保证只有一个0

    //输入:45.000

    //输出:45.0

     public static string trim0(string ls_original)
        {
          int iLength, j;
          j = 0;
          //iLength=len(ls_original);
          iLength = ls_original.Length;

          string ls_temp;
          ls_temp = ls_original;

          string strR1;

          if (iLength > 2)
          {

            //strR1=right(ls_original,1);
            strR1 = ls_original.Substring(ls_original.Length - 1, 1);

            do
            {
              j++;

              //ls_temp=left(ls_original,iLength - j);
              ls_temp = ls_original.Substring(0, iLength - j);

              //strR1=right(ls_temp,1);
              strR1 = ls_temp.Substring(ls_temp.Length - 2, 1);

            }
            while (strR1 == "0");

          }

          //如果被删除光了,说明它原来就是0

          if (ls_temp == "")
          {
            ls_temp = "0";
          }


          //如果最后一个字符是".",再在后面加个"0"
          //strR1 = right(ls_temp, 1);
          strR1 = ls_temp.Substring(ls_temp.Length - 1, 1);

          if (strR1 == ".")
          {
            ls_temp = ls_temp + "0";
          }

          return ls_temp;
        }//end

  • 相关阅读:
    二分、冒泡、选择、插入排序
    15行python代码,帮你理解令牌桶算法
    mybatis 的排序方式用参数传入 但是无法正常排序
    js事件篇
    ajax详解
    kafka概要设计
    HttpClient简述
    双十一问题:在洪峰数据来临的瞬间,redis出现连接超时异常
    双十一问题:kafka消费能力低下原因思考
    Timer类注意事项
  • 原文地址:https://www.cnblogs.com/quietwalk/p/2079904.html
Copyright © 2011-2022 走看看