How to control the decimal values ?

Hi

I want to control the decimals over the Math.round function. I used the following statement

class Ts

{

publicstaticvoid main(String args[])

{

double x=0.0;

double y=0.0D;

double z=0.0;

x=16094.712;

y=18.123;

z=x+y;

z= Math.round(z);

System.out.println("x"+z);

}

}

The result is 16113.0

but i need the 2 decimal values.

Please give me alternative solutions

Thankx

Merlina

[863 byte] By [MerlinRosinaa] at [2007-10-2 6:45:08]
# 1
Multiply by 100. Round. Divide by 100.
DrClapa at 2007-7-16 13:53:46 > top of Java-index,Java Essentials,Java Programming...
# 2
Thanksis there another way to control the decimals please tell me...i was try this waystockqty=Math.round(stockqty,+2)but it dos't work..Please tell me the alternative way ..ThankxMerlina
MerlinRosinaa at 2007-7-16 13:53:46 > top of Java-index,Java Essentials,Java Programming...
# 3
If you just need the rounding for display purposes, have a look at theDecimalFormat class.kind regards,Jos
JosAHa at 2007-7-16 13:53:46 > top of Java-index,Java Essentials,Java Programming...