数字运算符和函数
ceil 向上取整/进一取整 mysql> select ceil(3.01); +------------+ | ceil(3.01) | +------------+ | 4 | +------------+ 1 row in set (0.40 sec) #取舍一取整,向下取整 mysql> select floor(3.99); +-------------+ | floor(3.99) | +-------------+ | 3 | +-------------+ 1 row in set (0.00 sec) #整数除法 mysql> select 3/4; +--------+ | 3/4 | +--------+ | 0.7500 | +--------+ 1 row in set (0.00 sec) #div mysql> select 3 div 4; +---------+ | 3 div 4 | +---------+ | 0 | +---------+ 1 row in set (0.00 sec) #取模/取余数,均为同一个概念 mysql> select 5.3 mod 3; +-----------+ | 5.3 mod 3 | +-----------+ | 2.3 | +-----------+ 1 row in set (0.00 sec) #power 幂运算,2个3次方 mysql> select power(2,3); +------------+ | power(2,3) | +------------+ | 8 | +------------+ 1 row in set (0.07 sec) #四舍五入 mysql> select round(3.6523,2); //保留2位小数点 +-----------------+ | round(3.6523,2) | +-----------------+ | 3.65 | +-----------------+ 1 row in set (0.00 sec) mysql> select round(3.6523,1); //保留1位小数点 +-----------------+ | round(3.6523,1) | +-----------------+ | 3.7 | +-----------------+ 1 row in set (0.00 sec) #数字截取,仅仅是对数字的截取,用途较少 mysql> select truncate(123.6523,2); +----------------------+ | truncate(123.6523,2) | +----------------------+ | 123.65 | +----------------------+ 1 row in set (0.00 sec) mysql> select truncate(123.652,1); +---------------------+ | truncate(123.652,1) | +---------------------+ | 123.6 | +---------------------+ 1 row in set (0.00 sec) mysql> select truncate(123.652,0); +---------------------+ | truncate(123.652,0) | +---------------------+ | 123 | +---------------------+ 1 row in set (0.00 sec)
无语言基础,自学python所做的各种笔记,欢迎大牛指点.