Home > Database > Mysql Tutorial > 函数:MySQL中取整函数round和floor_MySQL

函数:MySQL中取整函数round和floor_MySQL

WBOY
Release: 2016-06-01 13:29:25
Original
1397 people have browsed it

bitsCN.com

函数:MySQL中取整函数round和floor

 

示例:

 round(123.456,2)      ------------   123.47ROUND   (   numeric_expression   ,   length   [   ,   function   ]   )   
Copy after login

参数

numeric_expression

精确数字或近似数字数据类型类别的表达式(bit 数据类型除外)。

length

是 numeric_expression 将要四舍五入的精度。length 必须是 tinyint、smallint 或int。当 length 为正数时,numeric_expression 四舍五入为 length 所指定的小数位数。当 length 为负数时,numeric_expression 则按 length 所指定的在小数点的左边四舍五入。

function

是要执行的操作类型。function 必须是 tinyint、smallint 或 int。如果省略 function 或 function 的值为 0(默认),numeric_expression 将四舍五入。当指定 0 以外的值时,将截断 numeric_expression。

round(123.456,   0)     -------         123.000     SELECT   FLOOR(123.45),   FLOOR(-123.45),   FLOOR($123.45)   ---------             ---------           -----------   123                         -124                     123.0000           SELECT   CEILING(123.45),   CEILING(-123.45),   CEILING(0.0) 
Copy after login

 

  以下

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