備註
社區興趣小組現在已從 Yammer 轉移到 Microsoft Viva Engage。 若要加入 Viva Engage 社群並參與最新的討論,請填寫 [ 要求存取財務和營運 Viva Engage 社群 表單 」 ,並選擇您要加入的社群。
本文說明數學執行時間函式。
這些函數執行數學計算。
腹肌
擷取實數的絕對值。 範例:
- abs(-100.0) 會 傳回值 100.0。
- abs(30.56) 傳 回值 30.56。
語法
real abs(real arg)
參數
| 參數 | Description |
|---|---|
| 引數 | 要取得絕對值的數字。 |
返回值
arg的絕對值。
Example
static void absExample(Args _args)
{
real r1;
real r2;
;
r1 = abs(-3.14);
r2 = abs(3.14);
if (r1 == r2)
{
print "abs of values are the same";
pause;
}
}
ACOS
擷取實數的弧餘弦。
備註
引數值超出 -1 到 1 的範圍會導致下列執行階段錯誤:「三角函數的引數超出範圍」。
語法
real acos(real arg)
參數
| 參數 | Description |
|---|---|
| 引數 | 要擷取的弧餘弦的數字。 |
返回值
arg 的弧餘弦。
Example
static void acosExample(Args _args)
{
real r;
str s;
;
r = acos(0.0);
s = strFmt("The arc cosine of 0.0 is %1 ", r);
print s;
pause;
}
阿辛
擷取實數的弧正弦。
備註
引數值超出 -1 到 1 的範圍會導致下列執行階段錯誤:「三角函數的引數超出範圍」。
語法
real asin(real arg)
參數
| 參數 | Description |
|---|---|
| 引數 | 計算圓弧正弦的數字。 |
返回值
指定數字的弧正弦。
備註
aSin(0.36) 傳 回 0.37。
阿坦
擷取實數的弧切。
語法
real atan(real arg)
參數
| 參數 | Description |
|---|---|
| 引數 | 要計算圓弧切線的數字。 |
返回值
指定數字的圓弧切線。
備註
aTan(0.36) 傳 回 0.35。
Example
static void atanExample(Args _args)
{
real r;
;
r = atan(1.0);
print strFmt("The Arc Tangent of 1.0 is %1", r);
pause;
}
corrFlagGet(corrFlagGet)
擷取實數的更正旗標狀態。
語法
int corrFlagGet(real arg)
參數
| 參數 | Description |
|---|---|
| 引數 | 要擷取狀態的旗標。 |
返回值
如果已設定旗標,則為非零值;如果清除旗標,則為 0 (零)。
Example
下列範例顯示 1。
static void corrFlagGetExample(Args _args)
{
real rr;
rr = corrFlagSet(0.36,2);
print(corrFlagGet(rr));
}
corr旗標集
控制實數的校正旗標。
語法
real corrFlagSet(real real, int arg)
參數
| 參數 | Description |
|---|---|
| real | 開啟或關閉更正旗標的編號。 |
| 引數 | 0 關閉旗幟;非零值以開啟旗標。 |
返回值
如果旗標現在已關閉,則為 0;如果旗標現在已開啟,則為非零值。
因為
擷取實數的餘弦。
語法
real cos(real arg)
參數
| 參數 | Description |
|---|---|
| 引數 | 要找到餘弦的數字。 |
返回值
指定數字的餘弦。
備註
arg 參數的值必須以弧度為單位。
Example
下列程式碼範例顯示 0.76。
static void cosExample(Args _arg)
{
real r;
;
r = cos(15);
print strFmt("Cos of 15 is %1", r);
pause;
}
科什
擷取實數的雙曲餘弦。
備註
引數值超出 -250 到 250 的範圍會導致下列執行階段錯誤:「三角函數的引數超出範圍」。
語法
real cosh(real arg)
參數
| 參數 | Description |
|---|---|
| 引數 | 計算餘弦的雙曲數。 |
返回值
指定數的雙曲餘弦。
備註
arg 參數的值必須以弧度為單位。
Example
static void coshExample(Args _arg)
{
real r;
;
r = cosh(0.1);
print "The hyperbolic cosine of 0.1 is " + num2Str(r, 2, 2, 1, 1);
pause;
}
十二月回合
將數字四捨五入到指定的小數位數。
語法
real decRound(real figure, int decimals)
參數
| 參數 | Description |
|---|---|
| 算 | 要四捨五入的數字。 |
| 小數 | 要四捨五入的小數位數。 |
返回值
指定數字的值,四捨五入至指定的小數位數。
備註
decimals 參數的值可以是正數、0 (零) 或負數。
- decRound(1234.6574,2) 傳回值 1234.66。
- decRound(1234.6574,0) 傳 回值 1235。
- decRound(1234.6574,-2) 傳回值 1200。
- decRound(12345.6789,1) 傳回值 12345.70。
- decRound(12345.6789,-1) 傳回值 12350.00。
exp (英文)
擷取指定實數的自然對數。
語法
real exp(real arg)
參數
| 參數 | Description |
|---|---|
| 引數 | 計算自然對數的實數。 |
返回值
指定實數的自然對數。
備註
計算出的自然對數是自然對數 e 提高到 arg 參數所指示的冪。
Example
static void expExample(Args _arg)
{
real r1;
real r2;
;
r1 = exp(2.302585093);
r2 = exp10(2.302585093);
print strFmt("exp of 2.302585093 is %1", r1);
print strFmt("exp10 of 230258 is %1", r2);
pause;
}
經驗10
擷取指定實數的以 10 為基數的反對數。
語法
real exp10(real decimal)
參數
| 參數 | Description |
|---|---|
| 十進位 | 計算以 10 為底的反對數的實數。 |
返回值
十進制參數值的以 10 為基礎的對數。
Example
static void exp10Example(Args _arg)
{
real r1;
real r2;
;
r1 = exp(2.302585093);
r2 = exp10(2.302585093);
print strFmt("exp of 2.302585093 is %1", r1);
print strFmt("exp10 of 230258 is %1", r2);
pause;
}
壓裂
擷取實數的小數部分。
語法
real frac(real decimal)
參數
| 參數 | Description |
|---|---|
| 十進位 | 要擷取小數部分的實數。 |
返回值
指定數字的小數部分。
備註
frac(12.345) 傳 回值 0.345。
日誌10
擷取實數的 10 位數對數。
語法
real log10(real arg)
參數
| 參數 | Description |
|---|---|
| 引數 | 要計算對數的數字。 |
返回值
指定數字的以 10 為底的對數。
備註
log10(200) 傳 回值 2.30。
日誌N
擷取指定實數的自然對數。
語法
real logN(real arg)
參數
| 參數 | Description |
|---|---|
| 引數 | 計算自然對數的數字。 |
返回值
指定數的自然對數。
備註
logN(45) 傳 回值 3.81。
max
擷取兩個指定值中較大的值。
anytype max(anytype object1, anytype object2)
參數
| 參數 | Description |
|---|---|
| 物件1 | 第一個值。 |
| 物件2 | 第二個值。 |
返回值
object1 和 object2 參數所指定的兩個值中較大的值。
備註
- max(12.0,12.1) 傳回值 12.1。
- max(2,33) 傳回值 33。
min
擷取兩個指定值中較小的值。
anytype min(anytype object1, anytype object2)
參數
| 參數 | Description |
|---|---|
| 物件1 | 第一個值。 |
| 物件2 | 第二個值。 |
返回值
object1 和 object2 參數所指定的兩個值中較小的值。
備註
min(2,33) 傳回值 2。
Example
static void minExample(Args _arg)
{
anytype a;
real r = 3.0;
real s = 2.0;
a = min(r, s);
print num2Str(a, 1, 2, 1, 1) + " is less than the other number.";
}
power
將實數提高到另一個實數的次方。
語法
real power(real arg, real exponent)
參數
| 參數 | Description |
|---|---|
| 引數 | 要計算的累膪的數字。 |
| 指數 | 要將 arg 參數指定的數字提高到的數字。 |
返回值
實數,即 arg 參數指定的數字與 指數 參數所指定數字的冪。
備註
- power(5.0,2.0) 傳 回值 25.0。
- power(4.0,0.5) 傳 回值 2.0。
四捨五入
將實數四捨五入到另一個實數的最接近的倍數。
語法
real round(real _arg, real _decimals)
參數
| 參數 | Description |
|---|---|
| _arg | 原始編號。 |
| _decimals | _arg 參數的值必須四捨五入為倍數的數字。 |
返回值
是 _decimals 參數所指定值的倍數,且最接近 _arg 參數所指定值的數字。
備註
若要將實數四捨五入到指定的小數位數,請使用 decround 函數。
備註
- round(123.45,5.00) 會傳回值 125.00。
- round(7.45,1.05) 會 傳回值 7.35。
- round(23.9,5.0) 會 傳回值 25.00。
- round(26.1,5.0) 會 傳回值 25.00。
罪
擷取實數的正弦。
語法
real sin(real _arg)
參數
| 參數 | Description |
|---|---|
| _arg | 要計算正弦的數字。 |
返回值
指定實數的正弦。
備註
_arg 參數的值必須以弧度為單位。
Example
static void sinExample(Args _arg)
{
real angleDegrees = 15.0;
real angleRadians;
real pi = 3.14;
real r;
;
angleRadians = pi * angleDegrees / 180;
r = sin(angleRadians);
print "sin of a "
+ num2Str(angleDegrees, 2, 2, 1, 1)
+ " degree angle is "
+ num2Str(r, 2, 10, 1, 1);
pause;
}
辛
擷取實數的雙曲正弦。
語法
real sinh(real _arg)
參數
| 參數 | Description |
|---|---|
| _arg | 計算雙曲正弦的數字。 |
返回值
指定實數的雙曲正弦。
備註
_arg 參數的值超出 -250 到 250 的範圍,會導致下列執行階段錯誤:「三角函數的引數超出範圍。」
Example
下列範例說明 sinh 函式。
static void sinhExample(Args _arg)
{
real angleDegrees = 45.0;
real angleRadians;
real pi = 3.14;
real r;
;
angleRadians = pi * angleDegrees / 180;
r = sinh(angleRadians);
print "sinh of a "
+ num2Str(angleDegrees, 2, 2, 1, 1)
+ " degree angle is "
+ num2Str(r, 2, 15, 1, 1);
pause;
}
鞣
擷取實數的正切。
語法
real tan(real arg)
參數
| 參數 | Description |
|---|---|
| 引數 | 要計算正切的實數。 |
返回值
指定實數的切線。
備註
arg 參數的值超出 -250 到 250 的範圍,會導致下列執行階段錯誤:「三角函數的引數超出範圍。」
Example
下列範例說明 tan 函數。
static void tanExample(Args _arg)
{
real r;
;
r = tan(250);
print strFmt("Tan of 250 is %1", r);
pause;
}
譚
擷取實數的雙曲正切。
語法
real tanh(real _arg)
參數
| 參數 | Description |
|---|---|
| _arg | 要計算雙曲正切的數字。 |
返回值
指定實數的雙曲正切。
Example
下列範例說明 tanh 函數。
static void tanhExample(Args _arg)
{
real r;
;
r = tanh(0.1);
print "The hyperbolic tangent of angle 0.1 is "
+ num2Str(r, 2, 10, 1, 1);
pause;
}
截
透過刪除任何小數位數來截斷實數。
語法
real trunc(real _decimal)
參數
| 參數 | Description |
|---|---|
| _十進位的 | 要截斷的數字。 |
返回值
相當於移除小數位數後 _decimal 參數值的數字。
備註
此函數一律會將數字四捨五入為完整的整數。
Example
下列範例會將 2.7147 截斷至 2.00。
static void truncExample(Args _arg)
{
real r;
;
r = trunc(2.7147);
print strFmt("r = %1", r);
pause;
}