mysql的数学函数开方_MySQL数学函数

NameDescription

Return the absolute value

Return the arc cosine

Return the arc sine

Return the arc tangent

Return the arc tangent of the two arguments

Return the smallest integer value not less than the argument

Return the smallest integer value not less than the argument

Convert numbers between different number bases

Return the cosine

Return the cotangent

Compute a cyclic redundancy check value

Convert radians to degrees

Integer division

Division operator

Raise to the power of

Return the largest integer value not greater than the argument

Return the natural logarithm of the argument

Return the natural logarithm of the first argument

Return the base-10 logarithm of the argument

Return the base-2 logarithm of the argument

Minus operator

Return the remainder

Modulo operator

Return the value of pi

Addition operator

Return the argument raised to the specified power

Return the argument raised to the specified power

Return argument converted to radians

Return a random floating-point value

Round the argument

Return the sign of the argument

Return the sine of the argument

Return the square root of the argument

Return the tangent of the argument

Multiplication operator

Truncate to specified number of decimal places

Change the sign of the argument

1.ABS

ABS(x)

返回x的绝对值

2.ACOS/ASIN/ATAN

ACOS(X)/ASIN(X):返回反余弦/正弦的值。如果X不在[-1,1]之间,则返回NULL。

ATAN(X):返回反正切的值。

3.CEILING/FLOOR

CEILING(x):返回大于x的最小整数值

FLOOR(x):返回小于x的最大整数值

4.CONV

CONV(N,from_base,to_base)

在不同的数字基之间变换数字。返回数字N的字符串数字,从from_base基变换为to_base基,如果任何参数是NULL,返回NULL。参数N解释为一个整数,但是可以指定为一个整数或一个字符串。最小基是2且最大的基是36。如果to_base是一个负数,N被认为是一个有符号数,否则,N被当作无符号数。 CONV以64位点精度工作。

mysql> select CONV("a",16,2);

-> '1010'

mysql> select CONV("6E",18,8);

-> '172'

mysql> select CONV(-17,10,-18);

-> '-H'

mysql> select CONV(10+"10"+'10'+0xa,10,10);

-> '40'

5.COS/COT/SIN/TAN

COS(X)/SIN(X):余弦/正弦。

COT(X)/TAN(X):余切/正切。

6.CRC32

CRC32(str):返回str的循环冗余码(32位的无符号整数)。如果str为NULL,返回NULL。

7.DEGREES/RADIANS

DEGREES(X):将弧度转换为角度。

RADIANS(X):将角度转换为弧度。

8.EXP

EXP(x)

返回值e(自然对数的底)的x次方

9.GREAST/LEAST

GREATEST(value1,value2,...)/LEAST(value1,value2,...):返回几个数中的最大值/最小值。如果有参数为NULL,则返回NULL。

mysql> SELECT GREATEST(2,0);

-> 2

mysql> SELECT GREATEST(34.0,3.0,5.0,767.0);

-> 767.0

mysql> SELECT GREATEST('B','A','C');

-> 'C'

mysql> SELECT LEAST(2,0);

-> 0

mysql> SELECT LEAST(34.0,3.0,5.0,767.0);

-> 3.0

mysql> SELECT LEAST('B','A','C');

-> 'A'

10.LN/LOG/LOG2/LOG10

LN(x):返回x的自然对数

LOG(X):等同于LN(X)

LOG(X,Y):返回x的以y为底的对数

LOG2(X):等同于LOG(2,X)

LOG10(X):等同于LOG(10,X)

11.MOD

MOD(x,y)

返回x/y的模(余数)

12.PI

PI()

返回pi的值(圆周率)

13.POW

POW(X,Y):返回X的Y次方。

14.RAND

RAND()/RAND(X)

返回0到1内的随机值,可以通过提供一个参数(种子)使RAND()随机数生成器生成一个指定的值。

15.ROUND

ROUND(x,y)

返回参数x的四舍五入的有y位小数的值

16.SIGN

SIGN(x)

返回代表数字x的符号的值。正数为1;0为0;负数为-1。

17.SQRT

SQRT(x)

返回一个数的平方根

18.TRUNCATE

TRUNCATE(X,D)

返回数字X截短为D位小数的结果。如果D大于小数位数,则返回原数;如果D为负数,则舍去小数,且将整数部分的后D位置为0。

mysql> SELECT TRUNCATE(1.223,1);

-> 1.2

mysql> SELECT TRUNCATE(1.999,1);

-> 1.9

mysql> SELECT TRUNCATE(1.999,0);

-> 1

mysql> SELECT TRUNCATE(-1.999,1);

-> -1.9

mysql> SELECT TRUNCATE(122,-2);

-> 100

mysql> SELECT TRUNCATE(10.28*100,0);

-> 1028

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值