The following example returns the largest integer equal to or less than 15.7:
SELECT FLOOR(15.7) "Floor" FROM DUAL;
Floor
----------
15
*******************************************************
The following example rounds a number to one decimal point:
SELECT ROUND(15.193,1) "Round" FROM DUAL;
Round
----------
15.2
The following example rounds a number one digit to the left of the decimal point:
SELECT ROUND(15.193,-1) "Round" FROM DUAL;
Round
----------
20
The following examples illustrate the difference between rounding NUMBER and floating-point number values. NUMBER values are rounded up (for positive values), whereas floating-point numbers are rounded toward the nearest even value:
SELECT ROUND(1.5), ROUND(2.5) FROM DUAL;
ROUND(1.5) ROUND(2.5)
---------- ----------
2 3
SELECT ROUND(1.5f), ROUND(2.5f) FROM DUAL;
ROUND(1.5F) ROUND(2.5F)
----------- -----------
2.0E+000 2.0E+000
*********************************************
The following examples truncate numbers:
SELECT TRUNC(15.79,1) "Truncate" FROM DUAL;
Truncate
----------
15.7
SELECT TRUNC(15.79,-1) "Truncate" FROM DUAL;
Truncate
----------
10
注:以上内容来自oracle 10g 帮助文档
本文通过具体实例介绍了Oracle10g中数学函数的应用,包括取整、四舍五入、截断等操作,并对比了不同数值类型在进行四舍五入时的区别。
1029

被折叠的 条评论
为什么被折叠?



