大富翁论坛
版权所有
作者: suger
标题: System.pas单元中的数学常规程序函数
注 : 这个单元包含高性能的算术、三角、对数、统计和金融方面的计算及FPU程序函数用于补充
Delphi 语言System.pas单元中的数学 常规程序函数
参考:
1)P.J. Plauger,"The Standard C Library", Prentice-Hall, 1992, Ch. 7. 《标准C程序库》
2)W.J. Cody, Jr., and W. Waite, "Software Manual For the Elementary Functions", Prentice-Hall, 1980.《
软件手册初步》
3)Namir Shammas, "C/C++ Mathematical Algorithms for Scientists and Engineers", McGraw-Hill, 1995, Ch 8.《C/C++ 数学的运算法则对于科学家和工程师》
4)H.T. Lau, "A Numerical Library in C for Scientists and Engineers", CRC Press, 1994, Ch. 6.《C语言中的数字的
程序库对于科学家和工程师》
5)"Pentium(tm) Processor User's Manual, Volume 3: Architecture and Programming Manual", Intel, 1994《Pentium(tm) 处理器使用手册,第 3 册: 体系结构和程序手册》
注意:
1) 对于有些函数,这个单元中涉及的概念或常数由Earl F. Glynn (efg2) 和 Ray Lischner (tempest-sw)提供。
2) 所有的角度参数三角函数的结果都用弧度表示
3) 下列大部分的三角和对数程序直接的映射到Intel 80387 FPU
4) 浮点机指令、输入域、输出范围和错误处理主要由 FPU 硬件决定
5) 汇编程序中的代码支持Pentium FPU 管线体系
l 常数
IEEE 浮点类型的范围, 包括非正规的
1) MinSingle = 1.5e-45; 最小Single数
2) MaxSingle = 3.4e+38; 最大Single数
3) MinDouble = 5.0e-324; 最小Double数
4) MaxDouble = 1.7e+308; 最大Double数
5) MinExtended = 3.4e-4932; 最小Extended数
6) MaxExtended = 1.1e+4932; 最大Extended数
7) MinComp = -9.223372036854775807e+18; 最小Comp数
8) MaxComp = 9.223372036854775807e+18; 最大Comp数
下列常数不应当被用于比较关系,仅仅用于分配。若要用于比较关系请使用IsNan 和 IsInfinity 函数。(已提供在后面)
9) NaN = 0.0 / 0.0; 非数 (*$EXTERNALSYM NaN*) (*$HPPEMIT 'static const Extended NaN = 0.0 / 0.0;'*)
10) Infinity = 1.0 / 0.0; 正无穷大 (*$EXTERNALSYM Infinity*) (*$HPPEMIT 'static const Extended Infinity = 1.0 / 0.0;'*)
11) NegInfinity = -1.0 / 0.0; 负无穷大 (*$EXTERNALSYM NegInfinity*) (*$HPPEMIT 'static const Extended NegInfinity = -1.0 / 0.0;'*)
一、三角函数
1) 函数 ArcCos(const X: Extended): Extended; (IN: |X| <= 1 OUT: [0..PI] 弧度)
2) 函数 ArcSin(const X: Extended): Extended; (IN: |X| <= 1 OUT: [-PI/2..PI/2] 弧度)
3) 函数 ArcTan2(const Y, X: Extended): Extended; (IN: |Y| < 2^64, |X| < 2^64, X <> 0 OUT
: [-PI..PI] 弧度)。计算 ArcTan(Y/X), 并且返回一个正确象限内的角度)
4) 过程 SinCos(const Theta: Extended; var Sin, Cos: Extended) register;
SinCos:比分别调用Sin 和Cos 计算同一个角度快两倍
5) 函数 Tan(const X: Extended): Extended;
6) 函数 Cotan(const X: Extended): Extended; { 1 / tan(X), X <> 0 }
7) 函数 Secant(const X: Extended): Extended; { 1 / cos(X) }
8) 函数 Cosecant(const X: Extended): Extended; { 1 / sin(X) }
9) 函数 Hypot(const X, Y: Extended): Extended; { Sqrt(X**2 + Y**2) }
二、角度单位换算程序
1) 函数 RadToDeg(const Radians: Extended): Extended; { 度数:= 弧度 * 180 / PI }
2) 函数 RadToGrad(const Radians: Extended): Extended; { 梯度:= 弧度 * 200 / PI }
3) 函数 RadToCycle(const Radians: Extended): Extended;{ 圆周:= 弧度 / 2PI }
4) 函数DegToRad(const Degrees: Extended): Extended; {弧度:= 度数* PI / 180}
5) 函数DegToGrad(const Degrees: Extended): Extended;
6) 函数DegToCycle(const Degrees: Extended): Extended;
7) 函数GradToRad(const Grads: Extended): Extended; {弧度:= 梯度 * PI / 200 }
8) 函数G