文章目录 [显示]
一组数学和三角设置函数。
17.1 MathAbs(绝对值)
double MathAbs( double value)
返回绝对值(模数)的指定的数值。
参量:
value – 数字值.
示例:
double dx=-3.141593, dy;
// calc MathAbs
dy=MathAbs(dx);
Print(“The absolute value of “,dx,” is “,dy);
// 输入数据: -3.141593的绝对值为3.141593
17.2 MathArccos(反余弦)
double MathArccos( double x)
MathArccos函数在范围0之内返回x 反余弦到ππ (在弧度上)。 如果x少于-1是或超出1, MathArccos返回FALSE。
参量:
x – 在-1和1范围的值反余弦将被计算。
示例:
double x=0.32696, y;
y=asin(x);
Print(“正弦”,x,” = “,y);
y=acos(x);
Print(“余弦 “,x,” = “,y);
//输入数据: 正弦 0.326960=0.333085
//输入数据:余弦 0.326960=1.237711
17.3 MathArcsin(反正弦)
double MathArcsin( double x)
在 -π/2 到 π/2 范围内函数MathArcsin正弦 x 。如果x 小于 -1 或超过1, 正弦返回NaN 。
参量:
x – 计算正弦的值。
示例:
double x=0.32696, y;
y=MathArcsin(x);
Print(“正弦”,x,” = “,y);
y=acos(x);
Print(“余弦 “,x,” = “,y);
//输入数据:正弦 0.326960=0.333085
//输入数据: 余弦 0.326960=1.237711
17.4 MathArctan(反正切)
double MathArctan( double x)
函数 MathArctan 返回 x的正切线值。 如果x为0, MathArctan 返回0。 MathArctan 返回值必须在-π/2 to π/2 弧度范围内。
参量:
x – 表示正切线的数字。
示例:
double x=-862.42, y;
y=MathArctan(x);
Print(“正切线 “,x,” is “,y);
//输入数据:正切线 -862.42 is -1.5696
17.5 MathCeil(最小大于)
double MathCeil( double x)
MathCeil函数返回一个最小超过或等于x的整数值。
参量:
x – 数值。
示例:
double y;
y=MathCeil(2.8);
Print(“上限 2.8 is “,y);
y=MathCeil(-2.8);
Print(“上限 -2.8 is “,y);
/*输入数据:
2.8 的上限为3
-2.8 的上限为-2*/
17.6 MathCos(余弦)
double MathCos( double value)
返回指定的余弦角。
参量:
value – 角度测量。
示例:
double pi=3.1415926535;
double x, y;
x=pi/2;
y=MathSin(x);
Print(“正弦(“,x,”) = “,y);
y=MathCos(x);
Print(“余弦(“,x,”) = “,y);
//输入数据: 正弦(1.5708)=1
// 余弦(1.5708)=0
17.7 MathExp(e求幂)
double MathExp( double d)
返回e的值升级到d的乘方。在溢出的情况下,函数返回INF (无限定),并且在底线返回0。
参量:
d – 数字指定乘方。
示例:
double x=2.302585093,y;
y=MathExp(x);
Print(“MathExp(“,x,”) = “,y);
//输入数据: MathExp(2.3026)=10
17.8 MathFloor(最大小于)
double MathFloor( double x)
MathFloor函数返回一个最大小于或等于x的整数值。
参量:
x – 数值。
示例:
double y;
y=MathFloor(2.8);
Print(“下限 2.8 is “,y);
y=MathFloor(-2.8);
Print(“下限 -2.8 is “,y);
/*输入数据:
下限2.8 为 2
下限 -2.8为-3*/
17.9 MathLog(自然对数)
double MathLog( double x)
如果成功,MathLog函数返回 x 的自然数。如果x 是负值,这些函数返回NaN (不确定值)。如果x 是0, 他们返回 INF (无限定)。
参量:
x – 发现的自然数值。
示例:
double x=9000.0,y;
y=MathLog(x);
Print(“MathLog(“,x,”) = “, y);
//输入数据: MathLog(9000)=9.10498
17.10 MathMax(最大)
double MathMax( double value1, double value2)
返回两个数字值的最大值。
参量:
value1 – 第一个数字值。
value2 – 第二个数字值。
示例:
double result=MathMax(1.08,Bid);
17.11 MathMin(最小)
double MathMin( double value1, double value2)
返回两个数字值的最小值。
参量:
value1 – 第一个数字值。
value2 – 第二个数字值。
示例:
double result=MathMin(1.08,Ask);
17.12 MathMod(浮点求余)
double MathMod( double value, double value2)
此函数返回两位数除法的保留浮点。
MathMod函数计算x / y 的保留浮点f ,这样x = i * y + f ,i 是整数, f 与 x是一样的标志, 并且 f 的绝对值小于y的绝对值。
参量:
value – 被除值。
value2 – 除值。
示例:
double x=-10.0,y=3.0,z;
z=MathMod(x,y);
Print(“保留数 “,x,” / “,y,” 为 “,z);
//输入数据: -10 / 3 的保留数为 -1
17.13 MathPow(指定数求幂)
double MathPow( double base, double exponent)
返回上升的基数指定的乘方(方次数值)。
参量:
base – 基数。
exponent – 方次数值。
示例:
double x=2.0,y=3.0,z;
z=MathPow(x,y);
Printf(x,” 的”,y,”次乘方为”, z);
//输入数据: 2 的 3次乘方为8
17.14 MathRand(随机数)
int MathRand( )
在0到32767的范围内MathRand函数返回一个随机整数。在调用MathRand之前,需要使用MathSrand 函数找寻随机整数。
示例:
MathSrand(TimeLocal());
// 显示 10个数字。
for(int i=0;i<10;i++ )
Print(“随机值 “, MathRand());
17.15 MathRound(四舍五入)
double MathRound(double value)
返回最近的四舍五入整数值。
参量:
value – 四舍五入值。
示例:
double y=MathRound(2.8);
Print(“2.8的四舍五入值为 “,y);
y=MathRound(2.4);
Print(” -2.4 的四舍五入值为 “,y);
//输入数据: 2.8的四舍五入值为 3
// -2.4 的四舍五入值为 -2
17.16 MathSin(正弦)
double MathSin(double value)
返回指定角的正弦。
参量:
value – 弧度角测量。
示例:
double pi=3.1415926535;
double x, y;
x=pi/2;
y=MathSin(x);
Print(“MathSin(“,x,”) = “,y);
y=MathCos(x);
Print(“MathCos(“,x,”) = “,y);
//输入数据: MathSin(1.5708)=1
// MathCos(1.5708)=0
17.17 MathSqrt(平方根)
double MathSqrt(double x)
MathSqrt函数返回x的平方根。如果x为负值,MathSqrt返回不确定值(与NaN相同)。
参量:
x – 否定数值。
示例:
double question=45.35, answer;
answer=MathSqrt(question);
if(question<0)
Print(“错误: MathSqrt 返回”,答案,” 答案”);
else
Print(“”,问题,”的平方根为 “, 答案);
//输入数据: 45.35 的平方根为6.73
17.18 MathSrand(随机数起点)
void MathSrand( int seed)
MathSrand() 函数设置一系列随机整数的开始点。重新初始化生成,使用1 作为自变数。找到的其他数值设置一个随机开始点。 MathRand 检测出生成的随机数字。调用 MathRand之前, 任何 MathSrand的生成调用需要按照找寻通过1的顺序调用MathSrand 。
参量:
seed – 找寻生成的随机数字。
示例:
MathSrand(TimeLocal());
// 显示10 数字。
for(int i=0;i<10;i++ )
Print(“随机值 “, MathRand());
17.19 MathTan(正切)
double MathTan( double x)
MathTan 返回 x的正切线。如果 x 大于等于263或者小于等于 -263,结果错误丢失,函数返回不确定值(与NaN相同)。
参量:
x – 弧度角
示例:
double pi=3.1415926535;
double x,y;
x=MathTan(pi/4);
Print(“MathTan(“,pi/4,” = “,x);
//输入数据: MathTan(0.7856)=1