1. Oracle Round 函数 (四舍五入)
描述 : 传回一个数值,该数值是按照指定的小数位元数进行四舍五入运算的结果。
如果两个整数都和value值等距离,那么round函数将返回较大的那个整数值。如果value是一个整数,则返回的就是value本身
SELECT ROUND( number, [ decimal_places ] ) FROM DUAL
参数:
number : 欲处理之数值
decimal_places : 四舍五入 , 小数取几位 ( 预设为 0 )
Sample :
select round(123.456, 0) from dual; 回传 123
select round(123.456, 1) from dual; 回传 123.5
select round(123.456, 2) from dual; 回传 123.46
select round(123.456, 3) from dual; 回传 123.456
select round(-123.456, 2) from dual; 回传 -123.46
var a = float.round(3.5); // 计算结果为a = 4;4和3与3.5等距离,取较大的数4
var b = float.round(-3.5); // 计算结果为b = -3
var c = float.round(0.5); // 计算结果为c = 1;1和0与0.5等距离,取较大的数1
var d = float.round(-0.5); // 计算结果为d = 0
Round 函数都是采用 Banker's rounding(银行家舍入)算法,即四舍六入五取偶
2.mod(number1,number2)
两个数值相除并返回其余数。(取模)
如果任一表达式为 Null,则 result 也为 Null。任一表达式为 Empty 时按 0 来处理。
如:round(3.5)=4 ,round(4.5)=4
3. SUBSTR( string, start_position, [ length ] )
string is the source string.
start_position is the position for extraction. The first position in the string is always 1 .
length is optional. It is the number of characters to extract. If this parameter is omitted, substr will return the entire string.
for example:
|
Be Continued ...