⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tools.pas

📁 基于高速铁路周边电动势计算的关键
💻 PAS
字号:
unit Tools;

interface

uses
  SysUtils, Math;
  
type
    TGraphPoint = Packed Record
    Val : Double;
    Str : String;
  end;

  Function Get1BitsAfterDoublePoint(varFloat : Double) :Double;
  Function Get2BitsAfterDoublePoint(varFloat : Double) :Double;
  Function Get4BitsAfterDoublePoint(varFloat : Double) :Double;
  Function Get6BitsAfterDoublePoint(varFloat : Double) :Double;
  Function Get8BitsAfterDoublePoint(varFloat : Double) :Double;

  procedure GenerateIncrementVal(const vdTotalLen:Double; const viPointNum:Integer; var vdIncre:Double; var viNumLen:Integer);
  Function  GetAvailableNumStr(vdVal:Double; viNumLen:Integer):String;

  procedure SinHCosH(const ee, x:Double; var vSinH, vCosH : Double);

implementation

procedure SinHCosH(const ee, x:Double; var vSinH, vCosH : Double);
var
  ex, enx : Double;
begin
  ex  := Power(ee, x);
  enx := Power(ee, -x);
  vSinH := (ex - enx)/2;
  vCosH := (ex + enx)/2;
end;

Function Get1BitsAfterDoublePoint(varFloat : Double) :Double;
var  strFloat : String;Begin  strFloat := Format('%8.1f', [varFloat]);  Result := StrToFloat(StrFloat);end;

Function Get2BitsAfterDoublePoint(varFloat : Double) :Double;
var  strFloat : String;Begin  strFloat := Format('%8.2f', [varFloat]);  Result := StrToFloat(StrFloat);end;

Function Get4BitsAfterDoublePoint(varFloat : Double) :Double;
var  strFloat : String;Begin  strFloat := Format('%8.4f', [varFloat]);  Result := StrToFloat(StrFloat);end;

Function Get6BitsAfterDoublePoint(varFloat : Double) :Double;
var  strFloat : String;Begin  strFloat := Format('%8.6f', [varFloat]);  Result := StrToFloat(StrFloat);end;

Function Get8BitsAfterDoublePoint(varFloat : Double) :Double;
var  strFloat : String;Begin  strFloat := Format('%8.8f', [varFloat]);  Result := StrToFloat(StrFloat);end;

function GetAvailableNumStr(vdVal: Double;  viNumLen: Integer): String;
begin
  case viNumLen of
    2: Result := FloatToStr(Get2BitsAfterDoublePoint(vdVal));
    4: Result := FloatToStr(Get4BitsAfterDoublePoint(vdVal));
    6: Result := FloatToStr(Get6BitsAfterDoublePoint(vdVal));
    8: Result := FloatToStr(Get8BitsAfterDoublePoint(vdVal));
  else Result := FloatToStr(vdVal);
  end;
end;

procedure GenerateIncrementVal(const vdTotalLen: Double; const viPointNum:Integer;
       var vdIncre: Double; var viNumLen: Integer);
var
  tempD : Double;
begin
  tempD := vdTotalLen/viPointNum;

  vdIncre  := Get2BitsAfterDoublePoint(tempD);
  viNumLen := 2;
  if vdIncre = 0 then
  begin
    vdIncre  := Get4BitsAfterDoublePoint(tempD);
    viNumLen := 4;
    if vdIncre = 0 then
    begin
      vdIncre  := Get6BitsAfterDoublePoint(tempD);
      viNumLen := 6;
      if vdIncre = 0 then
      begin
        vdIncre  := Get8BitsAfterDoublePoint(tempD);
        viNumLen := 8;
        if vdIncre = 0 then
        begin
          vdIncre  := tempD;
          viNumLen := 100;
        end;
      end;
    end;
  end;
end;


end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -