求 math 数学库 pascal 的

来源:百度知道 编辑:UC知道 时间:2024/05/27 02:40:21

Math库实用汇总
在FP中,Math库为我们提供了丰富的数学函数。以下介绍在OI中可能会用到的Math库中一些函数、过程。
使用方法:在程序头用Uses语句加载Math库
例子:
Program Ex_Math;
Uses Math;
Begin
Writeln(hypot(3,4));
End.
函数介绍:
 hypot
原型:function hypot(x:float;y:float):float
功能:返回直角三角形中较长边的长度,也就是sqrt(sqr(x)+sqr(y))
 ceil
原型:function ceil(x:float):Integer
功能:返回比参数大的最小整数
引发错误:在x超出Integer的范围时会引发溢出错误
 floor
原型:function floor(x:float):Integer
功能:返回参数小的最大整数
引发错误:在x超出Integer的范围时会引发溢出错误
 power
原型:function power(base:float;exponent:float):float
功能:返回base的exponent次方
引发错误:在base为负数且exponent为小数时
 intpower
原型:function intpower(base:float;const exponent:Integer):float
功能:返回base的exponent次方
 ldexp
原型:function ldexp(x:float;const p:Integer):float
功能:返回2的p次方乘以x
 log10
原型:function log10(x:float):float
功能:返回x的常用对数