cppreference.com -> 标准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 %d\n", 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().

标准c数学函数使用方法的更多相关文章

  1. C++ 第九课 标准c数学函数

    abs() 求绝对值 acos() 求反余弦 asin() 求反正弦 atan() 求反正切 atan2() 求反正切,按符号判定象限 ceil() 求不小于某值的最小整数 (求上界) cos() 求 ...

  2. java中的数学函数Math方法记录

    1,三角函数与属性Math.sin() -- 返回数字的正弦值Math.cos() -- 返回数字的余弦值Math.tan() -- 返回数字的正切值Math.asin() -- 返回数字的反正弦值M ...

  3. 0513JS数组内置方法、数学函数、时间函数

    |数组中常用的内置方法|-push()与pop()|--push()是往数组的尾部添加,同时返回新数组的长度 var attr = [1,2,3,4,5];var attr2 = [6,7,8,9,0 ...

  4. java数学函数Math类中常用的方法

    Math类提供了常用的一些数学函数,如:三角函数.对数.指数等.一个数学公式如果想用代码表示,则可以将其拆分然后套用Math类下的方法即可. Math.abs(12.3);               ...

  5. 标准c内存函数的使用方法

    标准c内存函数 calloc 语法:     #include <stdlib.h>   void *calloc( size_t num, size_t size ); 功能: 函数返回 ...

  6. cocos2d-x:懒人数学函数

    做游戏开发,要用到比较多的数学计算,对于程序员来说,还是用一种懒一点的方法,cocos2d-x方便开发者投机取巧...提供了很多方便的的数学函数,方便我们的数学计算.以下是在网上收集到的一些常用的数学 ...

  7. java数学函数库 API(转)

    原文地址:http://www.24xuexi.com/w/2011-11-08/98206.html 首先给大家看看Math类所提供的主要方法,下面的列表给出了Math类的主要方法,如果要理解Mat ...

  8. 【函数】Oracle函数系列(2)--数学函数及日期函数

    [函数]Oracle函数系列(2)--数学函数及日期函数 1  BLOG文档结构图 2  前言部分 2.1  导读和注意事项 各位技术爱好者,看完本文后,你可以掌握如下的技能,也可以学到一些其它你所不 ...

  9. iOS math.h数学函数

    在实际工作中有些程序不可避免的需要使用数学函数进行计算,比如地图程序的地理坐标到地图坐标的变换.Objective-C做为ANSI C的扩展,使用C标准库头文件<math.h>中定义的数学 ...

随机推荐

  1. Ionic学习笔记4_ionic路由(页面切换)

    1.1.  ionic路由机制: 状态 1.2.  ion-nav-view <body ng-controller="firstCtrl"> <a class= ...

  2. 使用maven结合requirejs管理前端脚本

    已有的web项目,一直使用Maven做工程管理,现阶段前端调整为使用requirejs来负责模块加载依赖,同时使用jasmine来完成前端的UT. 便与在maven下统一管理,简单整理了下合在一起的使 ...

  3. repaint和reflow的相关知识

    一个页面由两部分组成: DOM:描述该页面的结构 render渲染:描述 DOM 节点 (nodes) 在页面上如何呈现 repaint重绘: 当 DOM 元素的属性发生变化 (如 color) 时, ...

  4. Java 学习笔记之读取jdbc.propertyes配置参数

    package test; import java.io.IOException; import java.io.InputStream; import java.util.Properties; p ...

  5. Webkit内核探究【2】——css简介

    注:[转载请注明文章来源.保持原样] 出处:http://www.cnblogs.com/jyli/archive/2010/01/31/1660364.html 作者:李嘉昱 CSS在Webkit中 ...

  6. asp.net 定时间点执行任务的简易解决办法

    这里的定时间点执行任务,指的是每天的某个时间执行一项任务. 比如每天凌晨七点的时候email发送一次报表. 这里首先想到的就是利用 Global.asax 文件来实现, 以下Global文件的内容. ...

  7. SlidingMenu——使用前的配置

    一: 首先下载lib:SlidingMenu.然后将起导入eclipse中,然后将其clean一下,重新生成R文件. 二: 因为SlidingMenu依赖ActionBarSherlock,所以需要下 ...

  8. Gallery学习————检测手机中是否存在外部存储设备

    在缓存数据的时,有时候会出现没有外部存储设备的情况,所以需要检测是否存在外部存储设备 /** * 检测外部存储设备 * * @param requireWriteAccess * @return */ ...

  9. C++中计算矩阵的行列式

    使用eigen库: 求行列式: #include <iostream> #include <Eigen/Dense> using namespace std; using na ...

  10. hdu 1815(二分+2-sat)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1815 题意:给出n个牛棚.两个特殊点S1,S2的坐标.S1.S2直连.牛棚只能连S1或S2,还有,某些 ...