程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> Delphi >> Delphi中的算術運算函數

Delphi中的算術運算函數

編輯:Delphi

 Delphi中的算術運算函數 以下內容為編編程網站諸網友共同翻譯的結果,如需轉載,請注明出處:http://www.togetherdev.com,如果您對翻譯Delphi的函數有興趣,可登錄編編程網站,如果對翻譯的內容有什麼看法,可以在回帖或在編編程網站中提出。AbsCeilExpFloorfracFrexpintintpowerLdexpmaxminpipolypowerroundsqrttruncsqr函數名ABS簡要介紹:Returns an absolute value. (取絕對值)所屬單元:System定義:function Abs(X);詳細解釋:

  Abs returns the absolute value of the argument, X.

  X is an integer-type or real-type expression.

  (Abs函數用於返回變量X的絕對值,X可以是一個整形的變量或實數型的變量)返回函數名ceil簡要介紹:Rounds variables up toward positive infinity.所屬單元:Math定義:function Ceil(X: Extended):Integer詳細解釋:Call Ceil to obtain the lowest integer greater than or equal to X. The absolute value of X must be less than MaxInt. For example:

  Ceil(-2.8) = -2

  Ceil(2.8) = 3

  Ceil(-1.0) = -1

  (調用ceil函數,返回大於或等於x的最小整數值。X的絕對值一定要小於最大整數值。例如:

  Ceil(-2.8) = -2

  Ceil(2.8) = 3

  Ceil(-1.0) = -1)返回函數名Exp簡要介紹:Returns the exponential of X.(Exp函數返回自然對數基底E的X次冪。)所屬單元:System定義:function Exp(X: Real): Real;詳細解釋:

  Exp returns the value of e raised to the power of X, where e is the base of the natural logarithms.

  (Exp返回e的X次冪的值,其中e是一個自然對數基底。)范例:var e : real; S : string;begin e := Exp(1.0); Str(ln(e):3:2, S); S := 'e = ' + FloatToStr(e) + '; ln(e) = ' + S; Canvas.TextOut(10, 10, S);end;返回函數名Floor簡要介紹:Rounds variables toward negative infinity.(取小於給定值的最大整數)所屬單元:Math定義:function Floor(X: Extended): Integer;詳細解釋:

Call Floor to obtain the highest integer less than or equal to X. For example:

  Floor(-2.8) = -3

  Floor(2.8) = 2

  Floor(-1.0) = -1

  Note: The absolute value of X must be less than MaxInt.

  (使用Floor函數以取得小於等於X的最大的整數,如:

  Floor(-2.8) = -3

  Floor(2.8) = 2

  Floor(-1.0) = -1

  注意:X的絕對值必須小於整形數的最大值)返回函數名Frac簡要介紹:Returns the fractional part of a real number(返回一個實數的小數部分)所屬單元:System定義:function Frac(X: Extended): Extended;詳細解釋:

  The Frac function returns the fractional part of the argument X.

  X is a real-type expression. The result is the fractional part of X; that is, Frac(X) = X - Int(X).

  (Frac函數返回參數X的小數部分,X是一個實型數,該函數的作用等價於Frac(X)=X-Int(X)。)范例:vara,b:Real;begina := 1.54;b := frac(a);end;此時,a= 1.54,b=0.54返回函數名Frexp簡要介紹:Separates the Mantissa and Exponent of X(分解開X的尾數和指數。)所屬單元:Math定義:procedure Frexp(X: Extended; var Mantissa: Extended; var Exponent: Integer) register;詳細解釋:

  Frexp returns the mantissa of X as Mantissa and the exponent as Exponent.(Frexp函數返回X的尾數用變量Mantissa和指數用變量Exponent)。返回函數名int簡要介紹:Returns the integer part of a real number.(返回一個實數類型的整數部分)所屬單元:System定義:function Int(X: Extended): Extended;詳細解釋:

  Int returns the integer part of X; that is, X rounded toward zero. X is a real-type expression.(Int函數返回參數X的整數部分,X為實數類型,函數結果為X經過負向捨入(向0捨入)實數。)

 范例:var R: Real;begin R := Int(123.456); { 123.0 } R := Int(-123.456); { -123.0 }end;返回函數名Intpower簡要介紹:Calculates the integral power of a base value.(計算基數的整數冪。)所屬單元:Math定義:function IntPower(Base: Extended; Exponent: Integer): Extended register;詳細解釋:

  計算機教程Delphi中的算術運算函數來自www.itwen.comIT WEN計算機教程網

  IntPower raises Base to the power specifIEd by Exponent

  (計算基數的整數冪。base為基數,Exponent為指數)范例: 返回函數名Ldexp簡要介紹:Calculates X * (2**P)所屬單元:Math定義:function Ldexp(X: Extended; P: Integer): Extended register;詳細解釋:

  Ldexp returns X times (2 to the power of P).

  (Ldexp計算X*(2**P),返回X的(2的P次冪)次冪。)返回函數名Max簡要介紹:Returns the greater of two numeric values.(取兩個數中的最大值)所屬單元:Math定義:

function Max(A,B: Integer): Integer;

overload;

function Max(A,B: Int64): Int64;

overload;

function Max(A,B: Single): Single;

overload;

function Max(A,B: Double): Double;

overload;

function Max(A,B: Extended): Extended;

overload;

  詳細解釋:

  Call Max to compare two numeric values. Max returns the greater value of the two.

  (返回兩個數值中的最大值。調用Max比較兩個數值。它返回二者中較大的一個值。)返回函數名Min簡要介紹:Returns the lesser of two numeric values.(取兩個數的最小值)所屬單元:Math定義:


function Min(A,B: Integer): Integer; overload;
function Min(A,B: Int64): Int64; overload;
function Min(A,B: Single): Single; overload;
function Min(A,B: Double): Double; overload;
function Min(A,B: Extended): Extended; overload;

  詳細解釋:

  Call Min to compare two numeric values. Min returns the smaller value of the two.

  (返回兩個數值中的最小值。調用Max比較兩個數值,它返回二者中較小的一個值。)返回函數名pi簡要介紹:Returns 3.1415926535897932385. (返回3.1415926535897932385.)所屬單元:System定義:function Pi: Extended;詳細解釋:

  Use Pi in mathematical calculations that require pi, the ratio of a circle's circumference to its diameter. Pi is approximated as 3.1415926535897932385.

  (使用Pi函數精確計算返回圓周率Pi,圓周率是一個圓的周長除以它的直徑。Pi的值近似於3.1415926535897932385.)返回函數名poly(本條翻譯無把握)簡要介紹:Evaluates a uniform polynomial of one variable at the value X.所屬單元:Math定義:function Poly(X: Extended; const CoefficIEnts: array of Double): Extended;詳細解釋:

  Call Poly to evaluate the polynomial represented by the Coefficients parameter at the point where the variable equals the value of the X parameter. The coefficIEnts are ordered in increasing powers of X:

  Coefficients[0] + Coefficients[1]*X + ... + CoefficIEnts[N]*(X**N)

  (Poly估計一個變量在同一多項式的X值。調用Poly評估由Coefficients參數表達的多項式在一位置的值等同於X參數的值。參數是順序的以X的冪增加:CoefficIEnts[0]+

 coefficients[1]*X+…..+CofficIEnts[n]*[X**N])返回函數名power簡要介紹:Raises Base to any power.(取一個實數的冪)所屬單元:Math定義:function Power(Base, Exponent: Extended): Extended;詳細解釋:

  Power raises Base to any power. For fractional exponents or exponents greater than MaxInt, Base must be greater than 0.

  (返回一個實數的冪。 當指數Exponent為小數或大於MaxInt時,底數Base必須大於0.)返回函數名Round簡要介紹:Returns the value of X rounded to the nearest whole number.(對一個實數進行四捨五入)所屬單元:System定義:function Round(X: Extended): Int64;詳細解釋:

  The Round function rounds a real-type value to an integer-type value.

  X is a real-type expression. Round returns an Int64 value that is the value of X rounded to the nearest whole number. If X is exactly halfway between two whole numbers, the result is always the even number.

  If the rounded value of X is not within the Int64 range, a run-time error is generated, which can be handled using the EInvalidOp exception.

  (Round返回X向最近整數值的捨入。

  函數將一個實型值捨入為一個整型值。X是一個實型表達式。Round返回一個長整型值,是離X最近的整數值。如果X是兩個整數值的正中間,結果是絕對值最大的一個。如果X的捨入值不是在長整型范圍內,一個運行時間錯誤將產生,可以使用EinvalidOp異常來處理)范例:

var S, T: string;begin Str(1.4:2:1, T);

S := T + ' rounds to ' + IntToStr(Round(1.4)) + #13#10;

Str(1.5:2:1, T);

S := S + T + ' rounds to ' + IntToStr(Round(1.5)) + #13#10;

Str(-1.4:2:1, T);

S := S + T + ' rounds to ' + IntToStr(Round(-1.4)) + #13#10;

Str(-1.5:2:1, T);

S := S + T + ' rounds to ' + IntToStr(Round(-1.5));

MessageDlg(S, mtInformation, [mbOk], 0);

end;

The Sqr function returns the square of the argument.
X is a floating-point expression. The result, of the same type as X, is the square of X, or X*X.

  (Sqr返回X得平方值,X是一個浮點型的數,返回值的類型與X 相同,值為X*X)范例:var

  S, Temp: string;

  begin

  Str(Sqr(5.0):3:1, Temp);

  S := '5 squared is ' + Temp + #13#10;

  Str(Sqrt(2.0):5:4, Temp);

  S := S + 'The square root of 2 is ' + Temp;

  MessageDlg(S, mtInformation, [mbOk], 0);

  end;返回函數名sqrt簡要介紹:Returns the square root of X.所屬單元:System定義:function Sqrt(X: Extended): Extended;詳細解釋:

X is a floating-point expression. The result is the square root of X.
(取X的平方根,X是一個浮點數,返回值也是個浮點數)范例:var
S, Temp: string;
begin
Str(Sqr(5.0):3:1, Temp);
S := '5 squared is ' + Temp + #13#10;
Str(Sqrt(2.0):5:4, Temp);
S := S + 'The square root of 2 is ' + Temp;
MessageDlg(S, mtInformation, [mbOk], 0);
end;

  返回函數名Trunc簡要介紹:Truncates a real number to an integer.(截取一個實數的整數部分)所屬單元:System定義:function Trunc(X: Extended): Int64;詳細解釋:

The Trunc function truncates a real-type value to an integer-type value. X is a real-type expression. Trunc returns an Int64 value that is the value of X rounded toward zero.
If the truncated value of X is not within the Int64 range, an EInvalidOp exception is raised.范例:var
S, T: string;
begin
Str(1.4:2:1, T);
S := T + ' Truncs to ' + IntToStr(Trunc(1.4)) + #13#10;
Str(1.5:2:1, T);
S := S + T + ' Truncs to ' + IntToStr(Trunc(1.5)) + #13#10;
Str(-1.4:2:1, T);
S := S + T + ' Truncs to ' + IntToStr(Trunc(-1.4)) + #13#10;
Str(-1.5:2:1, T);
S := S + T + ' Truncs to ' + IntToStr(Trunc(-1.5));
MessageDlg(S, mtInformation, [mbOk], 0);end;





 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved