1
我使用此代碼的十進制值向下取整到25 即一個倍數,如果值是33.60它應該輪33.50甲骨文四捨五入問題
create or replace
PROCEDURE "TEST1" (PQUERY IN VARCHAR2) as
prNspValue number(14,2) :='';
p_percentage_Value number(4,2) :='';
begin
prNspValue:=33.60;
dbms_output.put_line(prNspValue);
p_percentage_Value:=substr(prNspValue,instr(prNspValue,'.')+1,length(prNspValue));
dbms_output.put_line(p_percentage_value);
p_percentage_Value:=p_percentage_Value-mod(p_percentage_Value,25);
dbms_output.put_line(p_percentage_value);
if(p_percentage_Value!=0)then
prNspValue:=substr(prNspValue,1,instr(prNspValue,'.'))+p_percentage_Value/100;
else
prNspValue:=substr(prNspValue,1,instr(prNspValue,'.'));
end if;
dbms_output.put_line(prNspValue);
end;
,但問題是當值33.60取爲33.6。所以它正在四捨五入到33.0。 我該如何糾正這段代碼?
啥子曾經我要舍down..ie的情況下,如果其33.9它應該給33.75等。 – Andromeda 2010-12-17 11:05:32
@jasim:你可以用'地板'而不是'圓'來回合(我更新了我的答案) – 2010-12-17 11:10:40