數學庫的基本函式

2022-08-10 08:51:16 字數 787 閱讀 5517

建議標頭檔案#include

下面是數學庫中一些經常容易用到的函式

1.絕對值(不同數值型別的對應的絕對值函式、標頭檔案):

(1)abs(int)               (整數) #include

(2)fabs(double)          (浮點數) #include

(3)labs(long)            (長整型)

** abs()和fabs()的標頭檔案是不同的,

2.log函式

(1)以e為底的對數計算方法:double a = log(x)

(2)以10為底的對數計算方法:double a = log10(x)

3.余弦函式 (正弦及正切函式類似)

函式說明:double cos(double x) --返回弧度角的余弦值,即引數x是弧度值

角度轉換為弧度 --  x * = acos(0.0)/90.0; cos(x);

x=x/180*pi;#define pi acos(-1)

4.平方根:sqrt(x)  x1/2

5.冪函式:pow(x,y)  --- xy

6.e的指數:exp(x)

7.取餘函式:double fmod(double x,double y)   

返回x除以y的餘數

8.取整函式:double ceil (double x)

(1)  ceil() 向上取整,(去除小數+1,除0外),

(2)  floor() 向下取整 (去除小數),

(3)  round() 四捨五入 

數學函式庫(基本版)

在c 語言中,除了 運算以外,其他的數 算都是通過函式的形式來實現的。這些數 算函式都在數學函式庫cmath中。要使用這些數學函式,必須在程式開始處寫上預編譯命令 include 列表如下 函式型別 cmath中對應的函式 絕對值函式 int abs int x double abs double ...

Oracle 基本數學函式

1 三角函式 sin asin sinh cosacos cosh tanatan tanh select sin 3.14159265 6 asin 1 sinh 1 from dual 其它的都類似 atan2 x,y 返回座標為 x,y 點的反正切 select atan2 3,3 from ...

OpenCV基本函式學習

include highgui.h int main int argc,char argv include highgui.h int main int argc,char argv cvreleasecapture capture cvdestroywindow example2 include ...