#include <math.h>

math.h是数学运算,应该都知道

1、 三角函数

double sin(double);正弦

double cos(double);余弦

double tan(double);正切

2 、反三角函数

double asin (double); 结果介于[-PI/2,PI/2]

double acos (double); 结果介于[0,PI]

double atan (double); 反正切(主值),结果介于[-PI/2,PI/2]

double atan2 (double,double); 反正切(整圆值),结果介于[-PI,PI]

3 、双曲三角函数

double sinh (double);

double cosh (double);

double tanh (double);

4 、指数与对数

double frexp(double value,int *exp);这是一个将value值拆分成小数部分f和(以2为底的)指数部分exp,并返回小数部分f,即f*2^exp。其中f取值在0.5~1.0范围或者0。

double ldexp(double x,int exp);这个函数刚好跟上面那个frexp函数功能相反,它的返回值是x*2^exp

double modf(double value,double *iptr);拆分value值,返回它的小数部分,iptr指向整数部分。

double log (double); 以e为底的对数

double log10 (double);以10为底的对数

double pow(double x,double y);计算x的y次幂

float powf(float x,float y); 功能与pow一致,只是输入与输出皆为单精度浮点数

double exp (double);求取自然数e的幂

double sqrt (double);开平方根

5 、取整

double ceil (double); 取上整,返回不比x小的最小整数

double floor (double); 取下整,返回不比x大的最大整数,即高斯函数[x]

6 、绝对值

double fabs (double);求实型的绝对值

double cabs(struct complex znum);求复数的绝对值

7 、标准化浮点数

double frexp (double f,int *p); 标准化浮点数,f = x * 2^p,已知f求x,p (x介于[0.5,1])

double ldexp (double x,int p); 与frexp相反,已知x,p求f

8 、取整与取余

double modf (double,double*); 将参数的整数部分通过指针回传,返回小数部分

double fmod (double,double); 返回两参数相除的余数

9 、其他

double hypot(double x,double y);已知直角三角形两个直角边长度,求斜边长度

double ldexp(double x,int exponent);计算x*(2的指数幂)

double poly(double x,int degree,double coeffs []);计算多项式

int matherr(struct exception *e);数学错误计算处理程序

我把math.h的源码找来了,来看看吧

// -*- C++ -*- compatibility header.

// Copyright (C) 2002-2020 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file math.h
 *  This is a Standard C++ Library header.
 */

#if !defined __cplusplus || defined _GLIBCXX_INCLUDE_NEXT_C_HEADERS
# include_next <math.h>
#else

#ifndef _GLIBCXX_MATH_H
#define _GLIBCXX_MATH_H 1

# include <cmath>

using std::abs;
using std::acos;
using std::asin;
using std::atan;
using std::atan2;
using std::cos;
using std::sin;
using std::tan;
using std::cosh;
using std::sinh;
using std::tanh;
using std::exp;
using std::frexp;
using std::ldexp;
using std::log;
using std::log10;
using std::modf;
using std::pow;
using std::sqrt;
using std::ceil;
using std::fabs;
using std::floor;
using std::fmod;

#if _GLIBCXX_USE_C99_MATH
using std::fpclassify;
using std::isfinite;
using std::isinf;
using std::isnan;
using std::isnormal;
using std::signbit;
using std::isgreater;
using std::isgreaterequal;
using std::isless;
using std::islessequal;
using std::islessgreater;
using std::isunordered;
#endif

#if __cplusplus >= 201103L && defined(_GLIBCXX_USE_C99_MATH_TR1)
using std::acosh;
using std::asinh;
using std::atanh;
using std::cbrt;
using std::copysign;
using std::erf;
using std::erfc;
using std::exp2;
using std::expm1;
using std::fdim;
using std::fma;
using std::fmax;
using std::fmin;
using std::hypot;
using std::ilogb;
using std::lgamma;
using std::llrint;
using std::llround;
using std::log1p;
using std::log2;
using std::logb;
using std::lrint;
using std::lround;
using std::nearbyint;
using std::nextafter;
using std::nexttoward;
using std::remainder;
using std::remquo;
using std::rint;
using std::round;
using std::scalbln;
using std::scalbn;
using std::tgamma;
using std::trunc;
#endif // C++11 && _GLIBCXX_USE_C99_MATH_TR1

// The mathematical special functions are only added to the global namespace
// by IS 29124, but not by C++17.
#if __cplusplus >= 201103L && __STDCPP_WANT_MATH_SPEC_FUNCS__ != 0
using std::assoc_laguerref;
using std::assoc_laguerrel;
using std::assoc_laguerre;
using std::assoc_legendref;
using std::assoc_legendrel;
using std::assoc_legendre;
using std::betaf;
using std::betal;
using std::beta;
using std::comp_ellint_1f;
using std::comp_ellint_1l;
using std::comp_ellint_1;
using std::comp_ellint_2f;
using std::comp_ellint_2l;
using std::comp_ellint_2;
using std::comp_ellint_3f;
using std::comp_ellint_3l;
using std::comp_ellint_3;
using std::cyl_bessel_if;
using std::cyl_bessel_il;
using std::cyl_bessel_i;
using std::cyl_bessel_jf;
using std::cyl_bessel_jl;
using std::cyl_bessel_j;
using std::cyl_bessel_kf;
using std::cyl_bessel_kl;
using std::cyl_bessel_k;
using std::cyl_neumannf;
using std::cyl_neumannl;
using std::cyl_neumann;
using std::ellint_1f;
using std::ellint_1l;
using std::ellint_1;
using std::ellint_2f;
using std::ellint_2l;
using std::ellint_2;
using std::ellint_3f;
using std::ellint_3l;
using std::ellint_3;
using std::expintf;
using std::expintl;
using std::expint;
using std::hermitef;
using std::hermitel;
using std::hermite;
using std::laguerref;
using std::laguerrel;
using std::laguerre;
using std::legendref;
using std::legendrel;
using std::legendre;
using std::riemann_zetaf;
using std::riemann_zetal;
using std::riemann_zeta;
using std::sph_besself;
using std::sph_bessell;
using std::sph_bessel;
using std::sph_legendref;
using std::sph_legendrel;
using std::sph_legendre;
using std::sph_neumannf;
using std::sph_neumannl;
using std::sph_neumann;
#endif // _GLIBCXX_USE_STD_SPEC_FUNCS

#if __cplusplus > 201703L
using std::lerp;
#endif // C++20

#endif // _GLIBCXX_MATH_H
#endif // __cplusplus

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值