Home > Database > Mysql Tutorial > mysql数值处理函数floor与round_MySQL

mysql数值处理函数floor与round_MySQL

WBOY
Release: 2016-06-01 13:41:20
Original
1110 people have browsed it

bitsCN.com
mysql数值处理函数floor与round  在mysql中,当处理数值时,会用到数值处理函数,如有一个float型数值2.13,你想只要整数2,那就需要下面的函数floor与round。 floor:函数只返回整数部分,小数部分舍弃。   round:函数四舍五入,大于0.5的部分进位,不到则舍弃。与floor不同。如下测试 mysql> select floor(5.1);+------------+| floor(5.1) |+------------+|          5 |+------------+1 row in set (0.00 sec) mysql> select floor(5.5);+------------+| floor(5.5) |+------------+|          5 |+------------+1 row in set (0.00 sec)   mysql> select round(5.2);+------------+| round(5.2) |+------------+|          5 |+------------+1 row in set (0.00 sec) mysql> select round(5.5);+------------+| round(5.5) |+------------+|          6 |+------------+1 row in set (0.00 sec)
  bitsCN.com

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template