zoukankan      html  css  js  c++  java
  • 检查浮点数精确位数

      function NumericPrecCheck(compnentCaption,text:string;numericPrec:integer;maxLimit:Integer):string;
      var
         E: extended;
      begin
        Result:='';
        try
          text:=Trim(text);
          E:=StrToFloat(text);
          if E>maxInt then
          begin
            Result:=compnentCaption+'超过范围'+inttostr(maxLimit)+', 请重新输入!';
          end;
          if ( pos( '.', text ) <> 0 ) and ( length( text ) - pos( '.', text ) >numericPrec )  then
          begin
              Result:=compnentCaption+'只能精确到小数点后' + IntToStr( numericPrec ) + '位,请重新输入!';
          end
          else
          begin
              Result:='格式正确';
          end;
        except
           Result:=compnentCaption+'为数字,请重新输入!';
        end;
      end;
  • 相关阅读:
    第二章例2-11
    第二章例2-10
    例2-11
    例2-9+2-10
    例2-7+例2-8
    例2-5+2-6
    例2-4
    例2-3
    例2-2
    例2-1
  • 原文地址:https://www.cnblogs.com/edisonfeng/p/2451864.html
Copyright © 2011-2022 走看看