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

  • 相关阅读:
    Promis.then()
    原生JS简单封装JSONP跨域获取数据
    原生JavaScript手写Ajax
    VS Code保存代码自动按eslint格式fix
    html data-xx 及 data()注意事项
    C#委托和事件
    vue devServer proxy 代理无效的问题
    vue .sync的使用
    js中,0的判断
    使用idea启动node项目的问题
  • 原文地址:https://www.cnblogs.com/quietwalk/p/2079904.html
Copyright © 2011-2022 走看看