Hmm, that does look a little strange. I would think that the result would be 1.20000000001E-8 but that might be due to the String formatter. If you are asking why does 12.0 show up as 12.0000000001 that is easy to explain. It is due to the binary representation of a decimal number.
 
Paul Franz

----- Original Message -----
To: JDJList
Sent: Thursday, September 19, 2002 10:31 AM
Subject: [jdjlist] Double multiplication

Hi
 
I have written a sample test program:
.........
 
public static void main (String args[]) 
    {
        Double
            op1 = new Double(12.0),
            op2 = new Double(1E-9),
            res = new Double ( op1.doubleValue()*op2.doubleValue() );
       
        System.out.println("op1: " + op1);
        System.out.println("op2: " + op2);
        System.out.println("res: " + res);
    }
The output is:
 
op1: 12.0000000001
op2: 1.0E-9
res: 1.2000000000100001E-8
What the @!# is going on?
 
How can I fix this?
 
Any help appreciated.
 
Thanks
 
Ivan
To change your JDJList options, please visit: http://www.sys-con.com/java/list.cfm
To change your JDJList options, please visit: http://www.sys-con.com/java/list.cfm

Reply via email to