整理:<cmath> (<math.h>)


资料一:

math.h头定义了各种数学函数和一个宏。这个库中所有可用的函数取double参数并返回double的结果。

库宏

只有一个在这个库中定义的宏:

S.N. 宏及说明
1 HUGE_VAL

当函数结果可能不是一个浮点数表示。正确的结果如果幅度太大,无法表示的功能设置errno为ERANGE表示一个范围错误,并且返回一个特定的值非常大宏HUGE_VAL或其否定( - HUGE_VAL)命名。

如果结果的幅度太小,而不是一个零值,则返回。在这种情况下,将errno可能会或可能不会被设置为ERANGE。

库函数

以下是math.h的标头中定义的函数:

S.N. 函数及说明
1 double acos(double x)
返回x的反余弦弧度。
2 double asin(double x)
返回x的正弦弧线弧度。
3 double atan(double x)
返回x的反正切值,以弧度为单位。
4 double atan2(doubly y, double x)
返回y / x的以弧度为单位的反正切值,根据这两个值,以确定正确的象限上的标志。
5 double cos(double x)
返回的弧度角x的余弦值。
6 double cosh(double x)
返回x的双曲余弦。
7 double sin(double x)
返回一个弧度角x的正弦。
8 double sinh(double x)
返回x的双曲正弦。
9 double tanh(double x)
返回x的双曲正切。
10 double exp(double x)
返回e值的第x次幂。
11 double frexp(double x, int *exponent)
The returned value is the mantissa and the integer yiibaied to by exponent is the exponent. The resultant value is x = mantissa * 2 ^ exponent.
12 double ldexp(double x, int exponent)
Returns x multiplied by 2 raised to the power of exponent.
13 double log(double x)
返回自然对数的x(基准-E对数)。
14 double log10(double x)
返回x的常用对数(以10为底)。
15 double modf(double x, double *integer)
返回的值是小数成分(小数点后的部分),并设置整数的整数部分。
16 double pow(double x, double y)
返回x的y次方。
17 double sqrt(double x)
返回x的平方根。
18 double ceil(double x)
返回大于或等于x的最小整数值。
19 double fabs(double x)
返回x的绝对值
20 double floor(double x)
返回的最大整数值小于或等于x。
21 double fmod(double x, double y)
返回的x除以y的余数。

资料二:

<cmath> (math.h)

C numerics library
Header  <cmath> declares a set of functions to compute common mathematical operations and transformations:

Functions


Trigonometric functions

Hyperbolic functions

Exponential and logarithmic functions

Power functions

Error and gamma functions

Rounding and remainder functions

Floating-point manipulation functions

Minimum, maximum, difference functions

Other functions

Macros / Functions

These are implemented as macros in C and as functions in C++:
Classification macro / functions

Comparison macro / functions

Macro constants


This header also defines the following macro constants (since C99/C++11):
macrotypedescription
MATH_ERRNO 
MATH_ERREXCEPT
intBitmask value with the possible values math_errhandling can take.
FP_FAST_FMA 
FP_FAST_FMAF 
FP_FAST_FMAL
intEach, if defined, identifies for which type fma is at least as efficient as x*y+z.
FP_INFINITE 
FP_NAN 
FP_NORMAL 
FP_SUBNORMAL 
FP_ZERO
intThe possible values returned by fpclassify.
FP_ILOGB0 
FP_ILOGBNAN
intSpecial values the ilogb function may return.

Types


资料三:

Standard library header <cmath>

   

This header was originally in the C standard library as <math.h>.

This header is part of the numeric library.

Macro constants

indicates the overflow value for floatdouble and long double respectively 
(macro constant)
(C++11)
evaluates to positive infinity or the value guaranteed to overflow a float 
(macro constant)
NAN
(C++11)
evaluates to a quiet NaN of type float 
(macro constant)
defines the error handling mechanism used by the common mathematical functions 
(macro constant)
Classification
(C++11)(C++11)(C++11)(C++11)(C++11)
indicates a floating-point category 
(macro constant)

Types

float_t
(C++11)
most efficient floating-point type at least as wide as float 
(typedef)
double_t
(C++11)
most efficient floating-point type at least as wide as double 
(typedef)

Functions

Basic operations
absolute value of a floating point value (|x|
(function)
remainder of the floating point division operation 
(function)
(C++11)
signed remainder of the division operation 
(function)
(C++11)
signed remainder as well as the three last bits of the division operation 
(function)
fma
(C++11)
fused multiply-add operation 
(function)
(C++11)
larger of two floating point values 
(function)
(C++11)
smaller of two floating point values 
(function)
(C++11)
positive difference of two floating point values (max(0, x-y)
(function)
(C++11)(C++11)(C++11)
not-a-number (NaN) 
(function)
Exponential functions
exp
returns e raised to the given power (ex
(function)
(C++11)
returns 2 raised to the given power (2x
(function)
(C++11)
returns e raised to the given power, minus one (ex-1
(function)
log
computes natural (base e) logarithm (to base e) (ln(x)
(function)
computes common (base 10) logarithm (log10(x)
(function)
(C++11)
base 2 logarithm of the given number (log2(x)
(function)
(C++11)
natural logarithm (to base e) of 1 plus the given number (ln(1+x)
(function)
Power functions
pow
raises a number to the given power (xy
(function)
computes square root (x
(function)
(C++11)
computes cubic root (3x
(function)
(C++11)
computes square root of the sum of the squares of two given numbers (x2
+y2

(function)
Trigonometric functions
sin
computes sine (sin(x)
(function)
cos
computes cosine (cos(x)
(function)
tan
computes tangent (tan(x)
(function)
computes arc sine (arcsin(x)
(function)
computes arc cosine (arccos(x)
(function)
computes arc tangent (arctan(x)
(function)
arc tangent, using signs to determine quadrants 
(function)
Hyperbolic functions
computes hyperbolic sine (sh(x)
(function)
computes hyperbolic cosine (ch(x)
(function)
hyperbolic tangent 
(function)
(C++11)
computes the inverse hyperbolic sine (arsinh(x)
(function)
(C++11)
computes the inverse hyperbolic cosine (arcosh(x)
(function)
(C++11)
computes the inverse hyperbolic tangent (artanh(x)
(function)
Error and gamma functions
erf
(C++11)
error function 
(function)
(C++11)
complementary error function 
(function)
(C++11)
gamma function 
(function)
(C++11)
natural logarithm of the gamma function 
(function)
Nearest integer floating point operations
nearest integer not less than the given value 
(function)
nearest integer not greater than the given value 
(function)
(C++11)
nearest integer not greater in magnitude than the given value 
(function)
(C++11)(C++11)(C++11)
nearest integer, rounding away from zero in halfway cases 
(function)
(C++11)
nearest integer using current rounding mode 
(function)
(C++11)(C++11)(C++11)
nearest integer using current rounding mode with 
exception if the result differs 
(function)
Floating point manipulation functions
decomposes a number into significand and a power of 2 
(function)
multiplies a number by 2 raised to a power 
(function)
decomposes a number into integer and fractional parts 
(function)
(C++11)(C++11)
multiplies a number by FLT_RADIX raised to a power 
(function)
(C++11)
extracts exponent of the number 
(function)
(C++11)
extracts exponent of the number 
(function)
(C++11)(C++11)
next representable floating point value towards the given value 
(function)
(C++11)
copies the sign of a floating point value 
(function)
Classification and comparison
(C++11)
categorizes the given floating point value 
(function)
(C++11)
checks if the given number has finite value 
(function)
(C++11)
checks if the given number is infinite 
(function)
(C++11)
checks if the given number is NaN 
(function)
(C++11)
checks if the given number is normal 
(function)
(C++11)
checks if the given number is negative 
(function)
(C++11)
checks if the first floating-point argument is greater than the second 
(function)
(C++11)
checks if the first floating-point argument is greater or equal than the second 
(function)
(C++11)
checks if the first floating-point argument is less than the second 
(function)
(C++11)
checks if the first floating-point argument is less or equal than the second 
(function)
(C++11)
checks if the first floating-point argument is less or greater than the second 
(function)
(C++11)
checks if two floating-point values are unordered 
(function)

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值