標準c數學函數

標準c數學函數
--------------------------------------------------------------------------------
abs
語法:

#include <stdlib.h>
int abs( int num );
功能: 函數返回參數num.的絕對值。例如:
int magic_number = 10;
cout << "Enter a guess: ";
cin >> x;
cout << "Your guess was " << abs( magic_number - x ) << " away from the magic number." << endl;
相關主題:
labs().

--------------------------------------------------------------------------------
acos
語法:

#include <math.h>
double acos( double arg );
功能:函數返回參數arg的反餘弦值。參數arg 應當在-1和1之間。
相關主題:
asin(), atan(), atan2(), sin(), cos(), tan(), sinh(), cosh(), and tanh().

--------------------------------------------------------------------------------
asin
語法:

#include <math.h>
double asin( double arg );
功能:函數返回參數arg的反正弦值。參數arg 應當在-1和1之間。
相關主題:
acos(), atan(), atan2(), sin(), cos(), tan(), sinh(), cosh(), and tanh().

--------------------------------------------------------------------------------
atan
語法:

#include <math.h>
double atan( double arg );
功能:函數返回參數arg的反正切值。
相關主題:
asin(), acos(), atan2(), sin(), cos(), tan(), sinh(), cosh(), and tanh().

--------------------------------------------------------------------------------
atan2
語法:

#include <math.h>
double atan2( double y, double x );
功能:函數計算y/x的反正切值,按照參數的符號計算所在的象限。
相關主題:
asin(), acos(), atan(), sin(), cos(), tan(), sinh(), cosh(), and tanh().

--------------------------------------------------------------------------------
ceil
語法:

#include <math.h>
double ceil( double num );
功能: 函數返回參數不小於num 的最小整數。例如,
y = 6.04;
x = ceil( y );
x爲7.0.
相關主題:
floor() and fmod().

--------------------------------------------------------------------------------
cos
語法:

#include <math.h>
double cos( double arg );
功能: 函數返回參數arg的餘弦值,arg以弧度表示給出。
相關主題:
asin(), acos(), atan(), sin(), atan2(), tan(), sinh(), cosh(), and tanh().

--------------------------------------------------------------------------------
cosh
語法:

#include <math.h>
double cosh( double arg );
功能: 函數返回參數arg的雙曲餘弦值。
相關主題:
asin(), acos(), atan(), sin(), atan2(), tan(), sinh(), cos(), and tanh().

--------------------------------------------------------------------------------
div
語法:

#include <stdlib.h>
div_t div( int numerator, int denominator );
功能: 函數返回參數numerator / denominator的商和餘數。結構類型div_t定義在stdlib.h中:
int quot; // 商數
int rem; // 餘數
例, 以下代碼顯示x/y的商和餘數:
div_t temp;
temp = div( x, y );
printf( "%d divided by %d yields %d with a remainder of %dn", x, y, temp.quot, temp.rem );
相關主題:
ldiv().

--------------------------------------------------------------------------------
exp
語法:

#include <math.h>
double exp( double arg );
功能: 函數返回參數returns e (2.7182818) 的arg次冪。
相關主題:
log().

--------------------------------------------------------------------------------
fabs
語法:

#include <math.h>
double fabs( double arg );
功能: 函數返回參數arg的絕對值。
相關主題:
abs().

--------------------------------------------------------------------------------
floor
語法:

#include <math.h>
double floor( double arg );
功能: 函數返回參數不大於arg的最大整數。例如,
y = 6.04;
x = floor( y );
x的值爲6.0.
相關主題:
ceil().

--------------------------------------------------------------------------------
fmod
語法:

#include <math.h>
double fmod( double x, double y );
功能: 函數返回參數x/y的餘數。
相關主題:
ceil(), floor(), and fabs().

--------------------------------------------------------------------------------
frexp
語法:

#include <math.h>
double frexp( double num, int *exp );
功能: 函數將參數num 分成兩部分: 0.5 和1之間的尾數(由函數返回)並返回指數exp。轉換成如下的科學計數法形式:
num = mantissa * (2 ^ exp)
相關主題:
ldexp().

--------------------------------------------------------------------------------
labs
語法:

#include <stdlib.h>
long labs( long num );
功能: 函數返回參數num的絕對值。
相關主題:
abs().

--------------------------------------------------------------------------------
ldexp
語法:

#include <math.h>
double ldexp( double num, int exp );
功能: 函數返回參數num * (2 ^ exp)。如果發生溢出返回HUGE_VAL。
相關主題:
frexp() and modf().

--------------------------------------------------------------------------------
ldiv
語法:

#include <stdlib.h>
ldiv_t ldiv( long numerator, long denominator );
功能: 函數返回參數numerator / denominator的商和餘數。結構類型 ldiv_t 定義在stdlib.h中:
long quot; // 商數
long rem; // 餘數
相關主題:
div().

--------------------------------------------------------------------------------
log
語法:

#include <math.h>
double log( double num );
功能: 函數返回參數num的自然對數。如果num爲負,產生域錯誤;如果num 爲零,產生範圍錯誤。
相關主題:
log10().

--------------------------------------------------------------------------------
log10
語法:

#include <math.h>
double log10( double num );
功能: 函數返回參數num以10爲底的對數。如果num爲負,產生域錯誤;如果num 爲零,產生範圍錯誤。
相關主題:
log().

--------------------------------------------------------------------------------
modf
語法:

#include <math.h>
double modf( double num, double *i );
功能: 函數將參數num 分割爲整數和小數,返回小數部分並將整數部分賦給i。
相關主題:
frexp() and ldexp().

--------------------------------------------------------------------------------
pow
語法:

#include <math.h>
double pow( double base, double exp );
功能: 函數返回以參數base 爲底的exp 次冪。如果base爲零或負和exp 小於等於零或非整數時,產生域錯誤。如果溢出,產生範圍錯誤。
相關主題:
exp(), log(), and sqrt().

--------------------------------------------------------------------------------
sin
語法:

#include <math.h>
double sin( double arg );
功能: 函數返回參數arg的正弦值,arg以弧度表示給出。
相關主題:
asin(), acos(), atan(), cosh(), atan2(), tan(), sinh(), cos(), and tanh().

--------------------------------------------------------------------------------
sinh
語法:

#include <math.h>
double sinh( double arg );
功能: 函數返回參數arg的雙曲正弦值。
相關主題:
asin(), acos(), atan(), cosh(), atan2(), tan(), sin(), cos(), and tanh().

--------------------------------------------------------------------------------
sqrt
語法:

#include <math.h>
double sqrt( double num );
功能: 函數返回參數num的平方根。如果num爲負,產生域錯誤。
相關主題:
exp(), log(), and pow().

--------------------------------------------------------------------------------
tan
語法:

#include <math.h>
double tan( double arg );
功能: 函數返回參數arg的正切值,arg以弧度表示給出。
相關主題:
asin(), acos(), atan(), cosh(), atan2(), sinh(), sin(), cos(), and tanh().

--------------------------------------------------------------------------------
tanh
語法:

#include <math.h>
double tanh( double arg );
功能: 函數返回參數arg的雙曲正切值。
相關主題:
asin(), acos(), atan(), cosh(), atan2(), tan(), sin(), cos(), and sinh().

發佈了19 篇原創文章 · 獲贊 2 · 訪問量 11萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章