# 数学函数

DLI所支持的数学函数如表1所示。

round(DOUBLE a)

DOUBLE

round(DOUBLE a, INT d)

DOUBLE

bround(DOUBLE a)

DOUBLE

HALF_EVEN模式四舍五入，与传统四舍五入方式的区别在于，对数字5进行操作时，由前一位数字来决定，前一位数字为奇数，增加一位，前一位数字为偶数，舍弃一位。例如：bround(7.5)=8.0，bround(6.5)=6.0

bround(DOUBLE a, INT d)

DOUBLE

floor(DOUBLE a)

BIGINT

ceil(DOUBLE a), ceiling(DOUBLE a)

BIGINT

rand(), rand(INT seed)

DOUBLE

exp(DOUBLE a), exp(DECIMAL a)

DOUBLE

ln(DOUBLE a), ln(DECIMAL a)

DOUBLE

log10(DOUBLE a), log10(DECIMAL a)

DOUBLE

log2(DOUBLE a), log2(DECIMAL a)

DOUBLE

log(DOUBLE base, DOUBLE a)

log(DECIMAL base, DECIMAL a)

DOUBLE

pow(DOUBLE a, DOUBLE p), power(DOUBLE a, DOUBLE p)

DOUBLE

sqrt(DOUBLE a), sqrt(DECIMAL a)

DOUBLE

bin(BIGINT a)

STRING

hex(BIGINT a) hex(STRING a)

STRING

conv(BIGINT num, INT from_base, INT to_base), conv(STRING num, INT from_base, INT to_base)

STRING

abs(DOUBLE a)

DOUBLE

pmod(INT a, INT b), pmod(DOUBLE a, DOUBLE b)

INT or DOUBLE

sin(DOUBLE a), sin(DECIMAL a)

DOUBLE

asin(DOUBLE a), asin(DECIMAL a)

DOUBLE

cos(DOUBLE a), cos(DECIMAL a)

DOUBLE

acos(DOUBLE a), acos(DECIMAL a)

DOUBLE

tan(DOUBLE a), tan(DECIMAL a)

DOUBLE

atan(DOUBLE a), atan(DECIMAL a)

DOUBLE

degrees(DOUBLE a), degrees(DECIMAL a)

DOUBLE

DOUBLE

positive(INT a), positive(DOUBLE a)

INT or DOUBLE

negative(INT a), negative(DOUBLE a)

INT or DOUBLE

sign(DOUBLE a), sign(DECIMAL a)

DOUBLE or INT

e()

DOUBLE

pi()

DOUBLE

factorial(INT a)

BIGINT

cbrt(DOUBLE a)

DOUBLE

shiftleft(TINYINT|SMALLINT|INT a, INT b)

shiftleft(BIGINT a, INT b)

INT

BIGINT

shiftright(TINYINT|SMALLINT|INT a, INT b)

shiftright(BIGINT a, INT b)

INT

BIGINT

shiftrightunsigned(TINYINT|SMALLINT|INT a, INT b),

shiftrightunsigned(BIGINT a, INT b)

INT

BIGINT

greatest(T v1, T v2, ...)

T

least(T v1, T v2, ...)

T

*必选