You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Laurent Michenaud <lm...@adeuza.fr> on 2001/11/14 16:38:30 UTC

Java and double

Hi,

Excuse me... this mail shouldnot be on this mailing list but
it is an hurry.

public class TestDouble
{
  static public void main(String args[]) {

        double val = 0.5055 * 1000 ;
        System.out.println( val );
  }
}

This program gives me the following results :
505.49999999999994

I've tried with Sun Jdk 1.2.2rev9, Sun jdk1.3.1 and Ibm Jdk 1.3.1.

Have u got informations about this ?
Can u try too ?

Thanks a lot and sorry again

Bye

Michenaud Laurent
- Adeuza -
[ Développeur Web - Administrateur Réseau ]


--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


RE: Java and double

Posted by Jim Rueschhoff <jr...@imsurenetwork.com>.
There is no problem.  Float and Double represents a number as a mantissa and
radix which produces a close but not exact representation of a number.  If
you round to a reasonable number of decimal places you will get the
"correct" result but if you insist on looking at the full precision of the
number you will get round off errors.  This is the very nature of floating
point numbers.



-----Original Message-----
From: Laurent Michenaud [mailto:lmichenaud@adeuza.fr]
Sent: Wednesday, November 14, 2001 8:39 AM
To: tomcat-user@jakarta.apache.org
Subject: Java and double


Hi,

Excuse me... this mail shouldnot be on this mailing list but
it is an hurry.

public class TestDouble
{
  static public void main(String args[]) {

        double val = 0.5055 * 1000 ;
        System.out.println( val );
  }
}

This program gives me the following results :
505.49999999999994

I've tried with Sun Jdk 1.2.2rev9, Sun jdk1.3.1 and Ibm Jdk 1.3.1.

Have u got informations about this ?
Can u try too ?

Thanks a lot and sorry again

Bye

Michenaud Laurent
- Adeuza -
[ Développeur Web - Administrateur Réseau ]


--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>



--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>