🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #16382

Re: 0.3-0.2=0.999999999998?

#16382
From: Harry Rowe
Date: Fri, 05 Mar 1999 00:00
33 lines
1755 bytes
>Would you care to explain how fully compliant IEEE 754 would handle
>that differently?
/*
Roedy,

Oops. Thats why you asked <G>. I find
you cannot  define 0.1 with finite precision
in base 2 with n digits of precision.

However, I was thinking that if Java allowed
the 10 byte double extended, gave the
programmer access to different IEEE
rounding modes, and did some sub-expression
handling differently, then perhaps the program
below would evaluate to true?

Frankly, I find these axioms a little scarry.

It is an interesting and very complex subject.
*/

public class TestReal {
   public static void main(String args[]) {
      double x = 0.3;
      double y = 0.2;
      double z = 0.1;
      if (x - y == z)
          System.out.println("true");
      else
        System.out.println("false");

      }
   }
Technical Details
Message-ID: <7botpj$geu$1@news.erinet.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <7blg56$2pl$1@zonnetje.NL.net> <7blrko$b87$1@news.erinet.com> <36e2c538.73748634@news.bctel.ca>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f5d71,3b89176b465afef
X-Google-Attributes: gidf5d71,public
X-Google-Thread: 10a146,3b89176b465afef
X-Google-Attributes: gid10a146,public
X-Google-Thread: f74b3,3b89176b465afef
X-Google-Attributes: gidf74b3,public
From: "Harry Rowe" <hrowe@erinet.com>
Subject: Re: 0.3-0.2=0.999999999998?
Date: 1999/03/05
Message-ID: <7botpj$geu$1@news.erinet.com>
X-Deja-AN: 451587689
References: <7blg56$2pl$1@zonnetje.NL.net> <7blrko$b87$1@news.erinet.com> <36e2c538.73748634@news.bctel.ca>
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3155.0
X-Complaints-To: usenet@news.erinet.com
X-Trace: news.erinet.com 920648307 16862 207.90.112.57 (5 Mar 1999 15:38:27 GMT)
Organization: Erinet Online Communications
NNTP-Posting-Date: 5 Mar 1999 15:38:27 GMT
Newsgroups: borland.public.jbuilder.java.language,comp.lang.java,comp.lang.java.programmer