I am not able to reproduce this,
can you be more specific on the source?

Ondrej

import java.io.*;

public class arithmetic {
   public static void main(String Args[])
   {
      double d1 = 172.5 / 1000;
      double d2 = 817.0 / 1000;
      double d3 = 4975.0 / 1000;

      Double D1 = new Double(d1);
      Double D2 = new Double(d2);
      Double D3 = new Double(d3);

      System.out.println(172.5 / 1000);
      System.out.println(817.0 / 1000);
      System.out.println(4975.0 / 1000);

      System.out.println(d1);
      System.out.println(d2);
      System.out.println(d3);

      System.out.println(D1);
      System.out.println(D2);
      System.out.println(D3);

      System.out.println(D1.doubleValue());
      System.out.println(D2.doubleValue());
      System.out.println(D3.doubleValue());

      System.out.println(d1 - 0.1725);
      System.out.println(d2 - 0.817);
      System.out.println(d3 - 4.975);

      System.out.println(d1 == 0.1725);
      System.out.println(d2 == 0.817);
      System.out.println(d3 == 4.975);
   }
}

[43] popp@FastFelix $ java arithmetic
0.1725
0.817
4.975
0.1725
0.817
4.975
0.1725
0.817
4.975
0.1725
0.817
4.975
0.0
0.0
0.0
true
true
true


Maarten van Leunen wrote:
> 
> Howdie,
> 
> I have this panel containing fields that I have to arithmetically
> change.
> 
> However, with some fields, with the following calculation I get the
> following results:
> 
> 172.5 / 1000 = 0.1725000001
> 817.0 / 1000 = 0.817000001
> 4975.0 / 1000 = 4.9750000005
> 
> Why is that and how do I stop it?
> 
> It looks like a Pentium-bug. *sigh*
> I use doubles and ordinary TextFields.
> 
> --
> Maarten van Leunen
> 
> Student - Fontys Institute of Technology Eindhoven
> e-mail: [EMAIL PROTECTED]
> http://www.il.fontys.nl/~maartenl
> http://lok.il.fontys.nl/

-- 
         ________________________________________________________ 
        |                                                        |       
        |                                                        |       
        |   http://www.geocities.com/SiliconValley/Lakes/6150    | 
        |                                                        |       
     _  |                                                        |  _    
    / ) |                                                        | ( \   
  _( (_ |  _              E-mail: [EMAIL PROTECTED]        _  | _) )_ 
 (((\ \)|_/ )________________________________________________( \_|(/
/)))
  \\\\ \_/ /                                                  \ \_/ //// 
   \      /                                                    \      /  
    \   _/                                                      \_   /   
    /__/                                                          \__\

Reply via email to