From owner-freebsd-questions Tue Apr 9 00:29:23 1996 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id AAA17499 for questions-outgoing; Tue, 9 Apr 1996 00:29:23 -0700 (PDT) Received: from barney.ife.no (barney.ife.no [128.39.229.49]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id AAA17494 for ; Tue, 9 Apr 1996 00:29:20 -0700 (PDT) Received: from tigern.ife.no by barney.ife.no (5.65/Ultrix3.0-C) id AA29958; Tue, 9 Apr 1996 09:28:45 +0200 From: stein@ife.no (Stein Morten Sandbech) Received: by tigern.ife.no ; Tue, 9 Apr 1996 09:28:18 +0200 Message-Id: <9604090728.AA17909@tigern.ife.no> Subject: Division error in javac / kaffe ? To: tim@sarc.city.ac.uk Date: Tue, 9 Apr 96 9:28:18 METDST Cc: questions@freebsd.org Mailer: Elm [revision: 70.85] Sender: owner-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk Hi ... I am fairly new to java, but I grabbed kaffe, version 0.54, for FreeBSD 2.1R just a couple of days ago. After testing some of the examples that are included in the package, I proceeded to test some code from the book "Java" by Tim Ritchey, and some of my own. I then stumbled on an error (can't be anything else can it ...?) regarding division of floats (double precision). The code and the results are listed below: class KaffeDivErr { public static void main ( String args[] ) { double v = 2.0, w = 5.0, W = 0.0; W = v / w; System.out.println("v = "+v); System.out.println("w = "+w); System.out.println("The division: W = v / w; yields : W="+W+"\n"); v = 345.1223111; w = 1203.210943; W = v / w; System.out.println("v = "+v); System.out.println("w = "+w); System.out.println("The division: W = v / w; yields : W="+W+"\n"); v = 12345.1223111; w = 1203.210943; W = v / w; System.out.println("v = "+v); System.out.println("w = "+w); System.out.println("The division: W = v / w; yields : W="+W+"\n"); v = 12345.1223111; w = 1203.210943; W = w / v; System.out.println("v = "+v); System.out.println("w = "+w); System.out.println("The division: W = w / v; yields : W="+W+"\n"); } } The output: v = 2 w = 5 The division: W = v / w; yields : W=2.5 v = 345.122 w = 1203.21 The division: W = v / w; yields : W=3.48633 v = 12345.1 w = 1203.21 The division: W = v / w; yields : W=0.0974645 v = 12345.1 w = 1203.21 The division: W = w / v; yields : W=10.2601 Correct me if I'm wrong, but this does not seem right :-) Stein Morten /* Stein M Sandbech Email: stein@ife.no ** ** Owner & technical manager Email: steinms@oslonett.no ** ** Ing. Stein M. Sandbech Phone: +47 6387 2300 ** ** Phone: +47 6380 6219 ** ** Asaktoppen 39, N-2045 Leirsund, NORWAY Fax: +47 6381 1168 */