"Burkhart,Kelly" wrote:
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> > Sent: Friday, September 24, 1999 6:58 AM
> > To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> > Subject: Float -> Double conversion bug ?
> >
> >
> > Dear all,
> >
> > If I try to put a float into a double variable the last bits of the
> > precision are total garbage ! If I try to put the float 0.3 into the a
> > double the result is 0.30000001192092896 !!! This could be a 'feature'
> > but it renders java (or at least jdk1.2) completely useless
> > for numerics
> > !
>
> This most likely has nothing to do with the Java implementation, but of the
> floating point characteristics of the underlying machine. If you set a
> double (in C) to 0.3, it's value is not necessarily 0.3 but something very
> very close:
well yes that is what I would expect, only number ^2 could be
represented properly, but what I think happens is that the 'new' double
is not properly initialized, ie all bytes are not set to '0'. Apparently
the exponent part is transferred correctly, but the mantissa part is
not, hence the error in the mantissa.
But what I would like to know is if other people experience the same,
how does a JVM under windows behave.
- Niels
--
Stehlin Merazzi Research sa. tel : +41 32 345 2123 - direct
http://2159224323 +41 79 607 1014 - mobile
Rue Dufour 109b +41 32 345 2120 - fax
CH-2500 Bienne 4, Switzerland
S/MIME Cryptographic Signature