常用数学函数介绍

 

15、abs

返回指定值的绝对值;

SQL>select abs(100),abs(-100) from dual;

  ABS(100)  ABS(-100)

---------- ----------

       100        100

 

16、acos

给出反余弦的值;

SQL>select acos(-1) from dual;

  ACOS(-1)

----------

3.14159265

 

17、asin

给出反正弦的值;

SQL>select asin(0.5) from dual;

 ASIN(0.5)

----------

0.52359877

 

18、atan

返回一个数字的反正切值;

SQL>select atan(1) from dual;

   ATAN(1)

----------

0.78539816

 

19、ceil

返回大于或等于给出数字的最小整数;

SQL>select ceil(3.14159265) from dual;

CEIL(3.14159265)

----------------

               4

特别说明:ceil返回的最小整数并不是四舍五入返回整数,而是返回给定值最近且大于给定值的整数。

 

20、cos

返回一个给定数字的余弦;

SQL>select cos(-3.14159265) from dual;

COS(-3.14159265)

----------------

              -1

 

21、cosh

返回一个数字反余弦值;

SQL>select cosh(20) from dual;

  COSH(20)

----------

242582597.

 

22、exp

返回一个数字e的n次方根;

SQL>select exp(2),exp(1) from dual;

    EXP(2)     EXP(1)

---------- ----------

7.38905609 2.71828182

 

23、floor

对给定的数字取整数;

SQL>select floor(2345.67) from dual;

FLOOR(2345.67)

--------------

          2345

特别说明:floor正好与ceil相反,向下取整数,不论小数点后面是什么数,一律截掉,只取前面整数。

 

24、ln

返回一个数字的对数值;

SQL>select ln(1),ln(2),ln(2.7182818) from dual;

     LN(1)      LN(2) LN(2.7182818)

---------- ---------- -------------

         0 0.69314718 0.99999998953

25、log(n1,n2)

返回一个以n1为底n2的对数;

SQL>select log(2,1),log(2,4) from dual;

  LOG(2,1)   LOG(2,4)

---------- ----------

         0          2

 

26、mod(n1,n2)

返回一个n1除以n2的余数;(取模函数)

SQL>select mod(10,3),mod(3,3),mod(2,3) from dual;

 MOD(10,3)   MOD(3,3)   MOD(2,3)

---------- ---------- ----------

         1          0          2

 

27、power

返回n1的n2次方根;

SQL>select power(2,10),power(3,3) from dual;

POWER(2,10) POWER(3,3)

----------- ----------

       1024         27

 

28、round和trunc

按照指定的精度进行舍入;round函数为四舍五入

SQL>select round(55.5),round(-55.4),trunc(55.5),trunc(-55.5) from dual;

ROUND(55.5) ROUND(-55.4) TRUNC(55.5) TRUNC(-55.5)

----------- ------------ ----------- ------------

         56          -55          55          -55

 

29、sign

取数字n的符号,大于0返回1,小于0返回-1,等于0返回0;

SQL>select sign(123),sign(-100),sign(0) from dual;

 SIGN(123) SIGN(-100)    SIGN(0)

---------- ---------- ----------

         1         -1          0

 

30、sin

返回一个数字的正弦值;

SQL>select sin(1.57079) from dual;

SIN(1.57079)

------------

0.9999999999

 

31、sinh

返回双曲正弦的值;

SQL>select sin(20),sinh(20) from dual;

   SIN(20)   SINH(20)

---------- ----------

0.91294525 242582597.

 

32、sqrt

返回数字n的根;

SQL>select sqrt(64),sqrt(10) from dual;

  SQRT(64)   SQRT(10)

---------- ----------

         8 3.16227766

 

33、tan

返回数字的正切值;

SQL>select tan(20),tan(10) from dual;

   TAN(20)    TAN(10)

---------- ----------

2.23716094 0.64836082

 

34、tanh

返回数字的n的双曲正切值;

SQL>select tanh(20),tan(20) from dual;

  TANH(20)    TAN(20)

---------- ----------

         1 2.23716094

 

35、trunc

按照指定的精度截取一个数;

SQL>select trunc(124.1666,-2),trunc(124.16666,2) from dual;

TRUNC(124.1666,-2) TRUNC(124.16666,2)

------------------ ------------------

               100             124.16

posted @ 2017-10-23 16:27  罗小川的博客  阅读(487)  评论(0编辑  收藏  举报