input 12.5 after DecimalFormat's ROUND_HALF_EVEN setScale, can get what?:)
hi, everybody.
i think ROUND_HALF_EVEN means when i input 12.5, after the process of setScale(0,BigDecimal.ROUND_HALF_EVEN), i can get 13.
but in fact, the out put is 12....
so. i tried 13.5....i get 14( that's what i want...)
and i tried more, all the result are right but 12.5..........
and i tred this sql in oracle
select round(12.5) from dual;
i got 13 now....
it seems that something wrong in my program or jdk. but i can not find out.
so i came here for your help...thanks a lot...
output......................
D:\AeroData\AeroPackage>java AeroCommon -12.5
AeroDebug 2004/08/23 15:56:
AeroDebug 2004/08/23 15:56 bdlAZUKARI_HOSHO_RISOKU_GAKU :-12
AeroDebug 2004/08/23 15:56 strAZUKARI_HOSHO_RISOKU_GAKU :-12
D:\AeroData\AeroPackage>java AeroCommon -13.5
AeroDebug 2004/08/23 15:56:
AeroDebug 2004/08/23 15:56 bdlAZUKARI_HOSHO_RISOKU_GAKU :-14
AeroDebug 2004/08/23 15:56 strAZUKARI_HOSHO_RISOKU_GAKU :-14
D:\AeroData\AeroPackage>java AeroCommon -15.5
AeroDebug 2004/08/23 15:56:
AeroDebug 2004/08/23 15:56 bdlAZUKARI_HOSHO_RISOKU_GAKU :-16
AeroDebug 2004/08/23 15:56 strAZUKARI_HOSHO_RISOKU_GAKU :-16
D:\AeroData\AeroPackage>java AeroCommon -15.13
AeroDebug 2004/08/23 15:56:
AeroDebug 2004/08/23 15:56 bdlAZUKARI_HOSHO_RISOKU_GAKU :-15
AeroDebug 2004/08/23 15:56 strAZUKARI_HOSHO_RISOKU_GAKU :-15
code..................
public static void main(String arg[]){
System.out.println("AeroDebug 2004/08/23 15:56:");
//DecimalFormat gakuFormater = new DecimalFormat("#,###,###,###,###.#");
DecimalFormat dfMoney = new DecimalFormat("#,###,###,###,###.#####");
BigDecimal bdlAZUKARI_HOSHO_RISOKU_GAKU = new BigDecimal(arg[0]);
String strAZUKARI_HOSHO_RISOKU_GAKU = "0";
if(bdlAZUKARI_HOSHO_RISOKU_GAKU != null){
bdlAZUKARI_HOSHO_RISOKU_GAKU = bdlAZUKARI_HOSHO_RISOKU_GAKU.setScale(0,BigDecimal.ROUND_HALF_EVEN);
System.out.println("AeroDebug 2004/08/23 15:56 bdlAZUKARI_HOSHO_RISOKU_GAKU :"+bdlAZUKARI_HOSHO_RISOKU_GAKU );
strAZUKARI_HOSHO_RISOKU_GAKU = dfMoney.format(bdlAZUKARI_HOSHO_RISOKU_GAKU);
}else{
}
System.out.println("AeroDebug 2004/08/23 15:56 strAZUKARI_HOSHO_RISOKU_GAKU :"+strAZUKARI_HOSHO_RISOKU_GAKU );
}

