Home > Database > Mysql Tutorial > Oracle round()函数与trunc()函数区别介绍

Oracle round()函数与trunc()函数区别介绍

WBOY
Release: 2016-06-07 17:55:51
Original
1167 people have browsed it

本文将详细介绍Oracle round()函数与trunc()函数区别,需要了解的朋友可以参考下

round(x[,y])
【功能】返回四舍五入后的值
【参数】x,y,数字型表达式,如果y不为整数则截取y整数部分,如果y>0则四舍五入为y位小数,如果y小于0则四舍五入到小数点向左第y位。
【返回】数字
【示例】 select round(5555.6666,2.1),round(5555.6666,-2.6),round(5555.6666) from dual;
返回: 5555.67 , 5600 , 5556
【相近】trunc(x[,y]) 返回截取后的值,用法同round(x[,y]),只是不四舍五入

trunc(x[,y])
【功能】返回x按精度y截取后的值
【参数】x,y,数字型表达式,如果y不为整数则截取y整数部分,如果y>0则截取到y位小数,如果y小于0则截取到小数点向左第y位,小数前其它数据用0表示。
【返回】数字
【示例】 select trunc(5555.66666,2.1),trunc(5555.66666,-2.6),trunc(5555.033333) from dual;
返回:5555.66 5500 5555
【相近】round(x[,y]) 返回截取后的值,用法同trunc(x[,y]),只是要做四舍五入
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