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

  • 相关阅读:
    4.单例模式
    3.适配器模式
    2.策略模式
    1.工厂模式
    机器学习
    何为技术领导力
    图像像素的算术操作
    图像对象创建和赋值的区别
    图像色彩空间转换
    notepad更改文档编码格式
  • 原文地址:https://www.cnblogs.com/quietwalk/p/2079904.html
Copyright © 2011-2022 走看看